Skip to content
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 #4009

Closed
mattjohnsonpint opened this issue Feb 27, 2015 · 9 comments
Closed

Bug in System.Globalization.PersianCalendar #4009

mattjohnsonpint opened this issue Feb 27, 2015 · 9 comments
Assignees

Comments

@mattjohnsonpint
Copy link
Contributor

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.

@mattjohnsonpint
Copy link
Contributor Author

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
Copy link
Contributor

ellismg commented Feb 27, 2015

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

@tarekgh
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
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
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
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
Copy link

jskeet commented Feb 28, 2015

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

@tarekgh
Copy link
Member

tarekgh commented Mar 2, 2015

That is right. it is astronomical.

@tarekgh
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.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@dotnet dotnet locked as resolved and limited conversation to collaborators Jan 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants