# any body know how to convert date widget to hijri date widget?

By
Jamshid Chungath
on 7/15/14, 1:17 AM 1,117 views

i want my date field in hijri format can you plz help me. How to convert english to hijri?

#### Remya

--Remya--

5617
| 7 8 8
Thiruvananthapuram, India
--Remya--

Working as an Senior ODOO developer. http://in.linkedin.com/pub/remya-r/69/a23/298

Remya
On 7/15/14, 2:47 AM

Convert English date to Hijri date

Code to convert English date to Hijri date:

def intPart(floatNum):
if floatNum < -0.0000001: return math.ceil(floatNum - 0.0000001)
return math.floor(floatNum + 0.0000001)

def Hijri2Gregorian(yr,mth,day):
jd1 = (11 * int(yr) + 3) / 30.0
jd2 = (int(mth) - 1) / 2.0
jd = jd1 + 354 * int(yr) + 30 * int(mth) - jd2 + int(day) + 1948440 - 385

if jd > 2299160:
l = jd + 68569
n = intPart((4 * l) / 146097.0)
l = l - intPart((146097 * n + 3) / 4.0)
i = intPart((4000 * (l + 1)) / 1461001.0)
l = l - intPart((1461 * i) / 4.0) + 31
j = intPart((80 * l) / 2447.0)
d = l - intPart((2447 * j) / 80.0)
l = intPart(j / 11.0)
m = j + 2 - 12 * l
y = 100 * (n - 49) + i + l
else:
j = jd + 1402
k = intPart((j - 1) / 1461.0)
l = j - 1461 * k
n = intPart((l - 1) / 365.0) - intPart(l / 1461.0)
i = l - 365 * n + 30
j = intPart((80 * i) / 2447.0)
d = i - intPart((2447 * j) / 80.0)
i = intPart(j / 11.0)
m = j + 2 - 12 * i
y = 4 * k + n + i - 4716

if(m<10):
m = str("0") + str(int(m))
else:
m = str(int(m))

if(d<10):
d = str("0") + str(int(d))
else:
d = str(int(d))

english_date = m + str("/") + d + str("/") +str(int(y))
return english_date

class hr_employee(osv.osv):
_inherit = "hr.employee"

'islamic_date_passport' : fields.char('Islamic Date(Passport Expiry)'),

def get_hijri_passport(self, cr, uid, ids, islamic_date_passport, context=None):
res = {}
datetype = islamic_date_passport
list = datetype.split('-')
day = str(list[0])
mth = str(list[1])
yr = str(list[2])
eng = Hijri2Gregorian(yr,mth,day)
return {'value':{'passport_expire':eng}}

hr_employee()

Remya , is it ok working this code ?.....

prakash
on 9/28/14, 8:39 AM

#### Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4663
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 4/2/18, 9:16 AM

We've https://www.odoo.com/apps/modules/11.0/web_hijri_date/ now, in v9 v10 too.

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

### Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

2 follower(s)

### Stats

 Asked: 7/15/14, 1:17 AM Seen: 1117 times Last updated: 4/2/18, 9:16 AM