ashkang / jcal

Jalali Calendar Library
http://nongnu.org/jcal
139 stars 24 forks source link

Unset “Daylight Savings Time” flag for Gregorian date input #15

Open meighti opened 6 years ago

meighti commented 6 years ago

Make sure “Daylight Savings Time” flag is NOT set, otherwise the conversion of a gregorian date to jalali form would be one day off.

As a test try this command: jdate '+%Y/%m/%d' -j 2018/03/22

The result should be: 1397/01/02

183amir commented 6 years ago

Do you think it would be useful to have a test case for this as well?

meighti commented 6 years ago

Specifically, this command: jdate '+%Y/%m/%d' -j `jdate '+%Y/%m/%d' -g 1397/01/02`

should give: 1397/01/02

meighti commented 6 years ago

It is easy to write a simple test in bash , like the e.g. I mentioned in previous comment.

Also in my opinion, it would have been safe to set: g.tm_hour = 12;

to avoid any DST flag issues.

183amir commented 6 years ago

I understand. I was suggesting to add a test in the test suite of the library but I cannot find any set of tests. There are only some commands to help test the library manually.

meighti commented 6 years ago

Amended my first commit, since further examination showed that contrary to my initial assumption, that one-liner didn't fix the issue. So I had to make a more conservative set of changes, in order to be completely sure that the amended solution gives a correct answer. Hopefully it is now fixed! :crossed_fingers:

meighti commented 6 years ago

As for 183amir's suggestion of having a test suite, I can only say at the moment that it would be welcomed if anybody has the time and desire to write one.