Hi,
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
d.day = 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).
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.
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
d.day = 1
MsgBox d.DayOfWeek.ToText[/code]
My guess is that Mojave ‘fixed’ that.
When I first read https://documentation.xojo.com/api/deprecated/date.html 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.
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.
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).
[/quote]
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: