JulianCalendar.GetDayOfYear returns unexpected results

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to use the System.Globalization.JulianCalendar.GetDayOfYear method
and I'm not getting what I expect. If I pass it "06/07/2006" it returns 145
instead of the expected 158. If I pass it "01/01/2006", it returns 353
instead of 1. Am I missing something? Thanks in advance.
 
Hi Robert,

Thanks for your post!

Yes, I can reproduce out this behavior.

I am not familiar with Julian Calendar, however, based on the
JulianCalendar Class description, it seems this behavior is by the nature
of Julian Calendar.

The root cause for this issue is stated in MSDN doc:
"Unlike the Gregorian calendar, the Julian calendar defines a leap year as
a year that is evenly divisible by four with no exceptions; therefore, the
calendar is inaccurate by one day every 128 years."

So we will get this result from MSDN:
"The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to
the 19th day of December in the year 2000 A.D. in the Julian calendar."

If you want to get the normal and accurate behavior of canlendar you may
use GregorianCalendar instead.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
RobertAA said:
I'm trying to use the System.Globalization.JulianCalendar.GetDayOfYear method
and I'm not getting what I expect. If I pass it "06/07/2006" it returns 145
instead of the expected 158. If I pass it "01/01/2006", it returns 353
instead of 1. Am I missing something? Thanks in advance.

This difference is the correction the world (gradually) made by
changing from the Julian calendar to what we use now, the Gregorian
calendar. Different countries converted over at different times; the
Russian October Revolution of 1917 now has its anniversary in November;
and some Orthodox churches still celebrate Christmas in January.
There's more at <http://en.wikipedia.org/wiki/Julian_calendar>

If (as it sounds) you are trying to get the sometimes-called 'Julian
date' of a given date - namely, the ordinal position of a date within
its year (although using 'Julian date' for this is strictly incorrect,
it's still widespread and commonly-understood) - use DateTime.DayOfYear
 
Back
Top