top of page

python convert date time to hindi digits & arabic characters

  • Writer: Askao Ahmed Saad
    Askao Ahmed Saad
  • Oct 19, 2017
  • 1 min read

# -*- coding: utf-8 -*-

'''

convert_date&time to hindi digits& arabic characters

Author: Askao

'''

import HTMLParser, datetime


number_list = [

"٠","١","٢","٣","٤",

"٥","٦","٧","٨","٩"

];

month_list = [

"يناير","فبراير","مارس","ابريل","مايو","يونيو","يوليو",

"أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"

];

h = HTMLParser.HTMLParser()

# convert each digit in the current day to hindi digits

arabic_day = ""

for n in str(datetime.datetime.now().day):

arabic_day += h.unescape(number_list[int(n)])

# convert current month to arabic month

arabic_month = month_list[datetime.datetime.now().month-1]

# convert each digit in the current year to hindi digits

arabic_year = ""

for n in str(datetime.datetime.now().year):

arabic_year += h.unescape(number_list[int(n)])

# convert each digit in the current hour to hindi digits

arabic_hour = ""

for n in str(datetime.datetime.now().hour):

arabic_hour += h.unescape(number_list[int(n)])

# convert each digit in the current minute to hindi digits

arabic_minute = ""

for n in str(datetime.datetime.now().minute):

arabic_minute += h.unescape(number_list[int(n)])


print "current date in arabic: " + arabic_day + " " + unicode(arabic_month, 'utf8') + ", " + arabic_year

print "current time in arabic: " + arabic_hour + ":" + arabic_minute



Recent Posts

See All
django crud scaffolding script

scaffold (views actions, templates, model_forms, routes) code for your models by few django shell commands scaffold cruds for your models...

 
 
 

Comments


Post: Blog2_Post
bottom of page