Date Confusion - Question to the Xojo Team


this question has certainly came up before. Every time I deal with a date and the date class, I come to the point where I wonder if only dates from 1.1.1970 can be processed correctly by the class (leap years, weeks, weekdays etc.). I have an application where dates around 1100 or 223 B.C. are also processed (dates before the introduction of the Gregorian calendar). Can the class also handle this “correctly”?

Maybe someone from Xojo @Paul Lefebvre can answer the question explicitly and include a clear internal reference in the documentation. I find this 1970 date confusing.


from the LR :

for dates not this century, and not previous century, I would rather make my own class to handle them correctly.

I do not know really, but maybe can handle it better?

From where do you found this 1970 reference ?

The LR ( does not have this date…

Are you using Xojo.Core.Date?

Yes, I use Xojo.Core.Date - Ask myself, if calling

Dim d1 As New Xojo.Core.Date(1160, 8, 1, Xojo.Core.TimeZone.Current)

will calculate the correct Date values (DayOfWeek, DayOfYear etc.)?

Xojo.Core.Date uses ICU (International Components for Unicode) for its date handling, supporting dates starting from 0001-Jan-01 and switching between Julian and Gregorian calendars on 1582-Oct-04.

Cool Paul, thanks. Does the old Date class also uses this components?

FYI the difference between mydate.TotalSeconds and xojo.core.mydate.SecondsFrom1970 is 2082848400

What about Jews / Muslim / Orient Churches / Whatever other calendars ? :wink:

No, it does not. It uses OS-specific components.

Be aware that macOS Mojave gives some different results than pre-Mojave:

Opened <>, maybe they can add a Note to Xojo.Core.Date — Xojo documentation

ICU can handle this

Apples NSDate and NSCalendar are based on the same principles (if not the same code at some level)

Xojo’s date class wraps the Calendar & Date into a single object and there’s no way to separate the two or tell Date to use a different Calendar system like Hijri, Julian etc