New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in System.Globalization.PersianCalendar #353

Closed
mj1856 opened this Issue Feb 27, 2015 · 9 comments

Comments

Projects
None yet
4 participants
@mj1856
Copy link
Contributor

mj1856 commented Feb 27, 2015

Console.WriteLine(new PersianCalendar().IsLeapYear(1));

Returns False on any machine with .NET Framework 4.6 CTP installed when targeting .NET 4.0 or higher.

Returns True when targeting .NET 3.5 or lower - or when targeting .NET 4.0+ on a machine without Framework 4.6.

@mj1856

This comment has been minimized.

Copy link
Contributor

mj1856 commented Feb 27, 2015

Note, according to MSDN:

A leap year is a year that, when divided by 33, has a remainder of 1, 5, 9, 13, 17, 22, 26, or 30. For example, the year 1370 is a leap year because dividing it by 33 yields a remainder of 17. There are approximately eight leap years in every 33-year cycle.

@ellismg

This comment has been minimized.

Copy link
Contributor

ellismg commented Feb 27, 2015

@tarekgh You might want to take a look at this.

@tarekgh

This comment has been minimized.

Copy link
Member

tarekgh commented Feb 27, 2015

We have changed the implementation of the Persian calendar to match the modern Iranian and Afghani calendar which is the Solar Hijri calendar. the calendar mainly used there.
both old and new implementation will have same results for date conversions in the year ranges 1800 (Gregorian) to 2123 (Gregorian). also you'll notice change in the leap years too.
we are going to fix the documentation too.

@tarekgh

This comment has been minimized.

Copy link
Member

tarekgh commented Feb 27, 2015

I forgot to mention Windows 10 also supported this calendar for some locales (like Iran) and used exactly same Solar Hijri calendar algorithm. so now Windows and .Net are fully consistent here

@jskeet

This comment has been minimized.

Copy link

jskeet commented Feb 27, 2015

So what does it do before 1800? As far as I'm aware, the regular Solar Hirji calendar used to be applied throughout history for PersianCalendar, i.e. the 33 year cycle of leap years 1, 5, 9, 13, 17, 22, 26, or 30 - which is what Wikipedia records as well in http://en.wikipedia.org/wiki/Iranian_calendars#Modern_calendar:_Solar_Hijri_.28SH.29

There's a second wikipedia article which may be relevant, however, indicating both an observational calendar and a "Solar Hijri algorithmic calendar" with cycles, grand cycles and great grand cycles...

Is there a good web source for what is implemented now? The latter wikipedia article lists several possibilities, by the looks of it. (For Noda Time, I'll need to work out whether to change our implementation or create a new calendar system with the same rules as the new one, but keep the existing implementation as well for those who want it...)

@tarekgh

This comment has been minimized.

Copy link
Member

tarekgh commented Feb 28, 2015

The accurate reference would be Calendrical Calculations book 3rd Edition by Nachum Dershowitz and Edward M. Reingold.
Also the link http://en.wikipedia.org/wiki/Solar_Hijri_calendar can be helpful too giving general idea about the Solar Hijri calendar

@jskeet

This comment has been minimized.

Copy link

jskeet commented Feb 28, 2015

Thanks - I assume this is following the astronomical rather than the arithmetic form?

@tarekgh

This comment has been minimized.

Copy link
Member

tarekgh commented Mar 2, 2015

That is right. it is astronomical.

@tarekgh

This comment has been minimized.

Copy link
Member

tarekgh commented Mar 2, 2015

Please let me know if you have any other question at any time.
@mj1856 please close the issue if there is any other question here.

@mj1856 mj1856 closed this Mar 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment