且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将波斯日期转换为朱利安或格列高利与基思木日历

更新时间:2021-10-19 23:07:53

我认为 toJD()不是你需要的: / p>

I think toJD() is not what you need:

var d = $.calendars.newDate(1388, 1, 1, 'persian', 'fa');
console.log("Persian date: "+d.toLocaleString()); // Persian date: 1388-01-01
var e = d.toJSDate();
console.log(e); // Sat Mar 21 2009 00:00:00 GMT+0100 (Romance Standard Time)

更新:对于您的评论,我看到问题没有解决,因为它将波斯日期转换为您的地区日期。就我在图书馆的参考中可以看到,没有办法告诉那个函数应该使用locale。所以正确的方式,正如作者提供的示范展示,正在创建另一个目标日历并传递当前一个作为参数:

UPDATE: For your comment I see the issue is not solved with this because it transforms the Persian date to your locale date. As far as I can see in the library's reference, there is no way to tell that function wich locale should be used. So the correct way, as the author's provided demo shows, is creating another target calendar and pass the current one as parameter:

var d = $.calendars.newDate(1388, 1, 1, 'persian', 'fa');
var e = $.calendars.newDate(d, 'gregorian', 'fa');