Closed Mds92 closed 9 years ago
Please note that in this library, months are 1-based. That is, the first month is month number 1, not 0. But in the Date object in JavaScript, months are 0-based. So you have to consider that difference when working with both of them.
To fix the problem you have to do something like this:
var gregorianDate = toGregorian(1394, 07, 01),
date = new Date(gregorianDate.gy, gregorianDate.gm - 1, gregorianDate.gd);
OK, but I think it's better to return zero base for gregorianDate
.
Thanks anyway.
Hey,
Thanks so much for this library.
I'm curious as to why you decided to go with 1-indexed based months, rather than 0-index? Is it for purely aesthetics or are there technical reasons?
It makes it very cumbersome to work with when converting dates back and forth.
One reason is I had some problems with 0-based months myself, while working with JS date object. Another is it seems odd to me that months start with 0 but days start with 1. Also I think the algorithm that is implemented, was 1-based and I tried to keep it like that.
@behrang Ok, makes sense. thank you
Ps. JavaScript Date is very odd :)
I've tested your library. I think there is a problem with it. Assume I wanna convert
1394/07/01
to Gregorian; So I wrote the following code:after converting
date
showsFri Oct 23 2015 00:00:00 GMT+0330 (Iran Standard Time)
whiles the first day of Mehr in 1394 isWed Sep 23 2015 00:00:00 GMT+0330 (Iran Standard Time)