Date object: different results in Mojave and pre-Mojave

after some users reported to me that an app of mine dealing with dates returned wrong dates, I looked into the matter.
Yes, Mojave and pre-Mojave systems return different dates when dealing with julian dates, that is, dates falling before 4 Oct 1582.

For instance: 1.1.1 (Jan 1, 1), whose DayOfWeek is 7 = Saturday

dim d as new date
d.Year = 1
d.Month = 1 = 1
d.GMTOffset = 0
d.TotalSeconds = d.TotalSeconds

dim s as String = "Day: " + str(d.Day) + EndOfLine + "Month: " + str(d.Month) + EndOfLine + "Year: " + str(d.Year) + EndOfLine + "Day of week: " + returnDayOfWeek(d.DayOfWeek)

MsgBox s

In pre-Mojave, DayOfWeek returns 1 (so one needs to apply a julian-gregorian conversion formula to get 7 out of it).

In Mojave, it returns 7; and so no need to apply conversion.

I think this new behavior should be added in the docs (unless I missed it).

Using macOS 10.14.5 and Xojo 2019r1

Wow; just wow… Make sure you file a feedback report.

Are you sure that it is a Xojo problem? I thought it was a “present” from Apple > Mojave.
Unfortunately I do not have at hand an older Xojo version to test.

Am not sure; but file a feedback report anyway and Xojo should investigate.

This code reports DayOfWeek as 2 with macOS 10.12.6 and 7 with macOS 10.14.5 (remote debug VM):

[code]dim d as new date
d.Year = 1
d.Month = 1 = 1

MsgBox d.DayOfWeek.ToText[/code]

My guess is that Mojave ‘fixed’ that.

When I first read I thought that dates can only go back to January 1, 1904, but then there is a note for Windows, that the API can only go back to Jan 1, 1601. Until today, I didn’t know that I can set Jan1, 0001 on mac. Also, I didn’t know that Jan 1, 0001 is Saturday and older macOS versions report it as Monday and now Mojave reports correctly as Saturday.

Let us wait and see if some Xojo engineer pops in…

I reported about 5 years ago that Mac and Win7 give different result for dates before 15??.

Not at my computer but if you search in feedback you should find the report. As far as I know it never got fixed.

In short: forget about using Xojo’s date for historical dates.

Also, what makes you think the dates are correct (or not) ?

Remember, the dates changes all along the centuries, they change differently depending on the part of the world you are in / consider.

At last, year 1 is just a mind view, this is not rock solid. When Christian people started to count the dates ?

Unless Xojo engineer talk, my advice is to create your own Date Class for these old times (to be sure it will be as accurate as possible).

Christmas is in January for some Christian, so !

if you have to use dates before 1900, you’ve better make your own classes and use them !

@Emile Schwarz [quote]Also, what makes you think the dates are correct (or not) ?[/quote]

Just the fact that other sources (online calendars) return the same dayOfWeek.
So let me refrase my opening sentence:

Have any of you tried this experiment with Xojo.Core.Date?

Hi Carlo,

what is the Date locale (your OS Date settings) ?

It may be correct for that or for your location or… Did you try to set your locale / OS to a middle East country (Orthodox religious settings) ?

Did you try a bit older dates (just like Caesar death or birth or just before the start of the Julian Calendar…) ?

This code shows 2 on macOS 10.12.6 and 7 on macOS 10.14.5:

dim d as ="0001-01-01") MsgBox d.DayOfWeek.ToText

@Greg O’Lone
No, I have not tried

But if possible I’d like to know if I should file a feedback report. Thanks.

@Emile Schwarz
The app tells users to set OS Calendars to Gregorian.
About older dates: it is sufficient for me to have the days going back (both as JulianDay-number and DayOfWeek) in a consistent way (if 1.1.1 is Saturday, then 31 Dic 1 BC is Friday etc.).
BTW: the app tells also users to take these dayOfWeek with a grain of salt.

But I think we are getting out of topic.

@Carlo Rubini

When in doubt, file a bug report, because:
1. If the result is wrong, it is a bug
2.If the result is right but undocumented, it is still a bug (in the documentation).

[quote=437036:@Carlo Rubini]I think this new behavior should be added in the docs (unless I missed it).

I think Carlo is not saying that there is a bug in Xojo and only wants for the docs to expand on this fact. I guess, because there is a warning on the docs about windows that say:

it could be possible to add something like:

Issue filed <>.

So I hope at least docs will get updated.