【源码】日历转换器:格里高利历、波斯历和伊斯兰历法

在这里插入图片描述

dateconv(Y,M,D,from_calend,to_calend)计算格里高利公历(“ce”)、波斯太阳历或日晷(“sh”)和伊斯兰历(“lh”)之间的日历转换。输出1x3数字数组向量[Y,M,D],和一个字符数组,该数组带有以波斯语、阿拉伯语或英语表示的打印日期。对于波斯历和伊斯兰历法,数字用东方阿拉伯数字表示。

dateconv(Y,M,D,from_calend,to_calend) computes bilateral date conversion between Gregorian Common Era (‘ce’), Persian Solar Hijri or Jalali (‘sh’), and Islamic Lunar Hijri (‘lh’) calendars. Outputs a 1x3 numeric array vector of [Y,M,D], and a character array with printed date with month names in Persian, Arabic, or English. For Persian and Islamic calendars, the numbers are shown in Eastern Arabic numerals.

For example:

[outdatenum,outdatetxt] = dateconv(2000,1,1,‘ce’,‘sh’) returns the equivalent date for Jan 1, 2000 in Persian Solar Hijri calendar:

[outdatenum,outdatetxt] = dateconv(2000,1,1,‘ce’,‘sh’)

outdatenum =

1378 10 11

outdatetxt =

‘۱۱ دی/جدی ۱۳۷۸’

datetoday

Today’s date is:

12-Nov-2020

۲۲ آبان/عقرب ۱۳۹۹

۲۶ ربيع-الأول ۱۴۴۲

Conversion takes place through the Julian Day Number. Each calendar is converted to and computed back from the Julian Day Number.

For Gregorian calendar, the algorithm by NASA/Goddard is adopted, which correctly computes the dates for Proleptic era (before 1582).

For Persian/ Jalali calendar, the algorithm is based on the method proposed by Musa Akrami (2014) and implemented by Soroush Rabiei (2017).

Check & tests:

The start of the Persian calendar epoch (1/1/475 SH) per Akrami’s 2,820 years cycle starts on Mar 15, 1096 (and NOT on March 21st as other date converter algorithms suggest):

dateconv(475,1,1,‘sh’,‘ce’)

ans =

1096 3 15

The first day of the Persian calendar starts on Mar 19, 622:

dateconv(1,1,1,‘sh’,‘ce’)

ans =

622 3 19

The first day of the Islamic Lunar Hijri starts on July 16, 622:

dateconv(1,1,1,‘lh’,‘ce’)

ans =

622 7 16

更多精彩文章请关注公众号:在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值