Page 1 of 1

dateItems show wrong day of the week

Posted: Sat Feb 08, 2025 4:23 pm
by Martin-HC
Hi,
Where I live it is Saturday, 8 February 2025. When I do this in the message box:
put the short date into d ;convert d to dateitems ; answer d
I get "2025,2,8,0,0,0,7"
The last item (7) says it is Sunday but it should be 6, Saturday.

Instead of short date I also tried the english date and the nternet date: all come out with 7 as day of week = Sunday.

Don't know if is related but I checked my date & time settings in Windows 10. It says that the first day of the week is Monday, so that should be 1 for Monday and 6 for Saturday, not 7.

I'm puzzled.

Re: dateItems show wrong day of the week

Posted: Sat Feb 08, 2025 4:44 pm
by richmond62
The Jewish week starts on Saturday night as soon as it gets dark. 8)

Re: dateItems show wrong day of the week

Posted: Sat Feb 08, 2025 5:42 pm
by FourthWorld
By default LC uses English time notation, allowing a means for consistent operations regardless of localized display formats.

If you want localized display formats see the useSystemDate property, which will alter the behavior of the convert command to take localized display into account, within the scope of the currently executing handler.

Re: dateItems show wrong day of the week

Posted: Sun Feb 09, 2025 11:19 am
by bogs
Martin-HC wrote:
Sat Feb 08, 2025 4:23 pm
Hi,
Where I live it is Saturday, 8 February 2025. When I do this in the message box:
put the short date into d ;convert d to dateitems ; answer d
I get "2025,2,8,0,0,0,7"
The last item (7) says it is Sunday but it should be 6, Saturday.

Instead of short date I also tried the english date and the nternet date: all come out with 7 as day of week = Sunday.

Don't know if is related but I checked my date & time settings in Windows 10. It says that the first day of the week is Monday, so that should be 1 for Monday and 6 for Saturday, not 7.

I'm puzzled.
Much as Richard points out, from the dictionary:
Lc Dictionary wrote: Use the dateItems keyword with the convert command to store a date and/or time.

Comments:
The dateItems format is a comma-separated list of numbers:
* the year
* the month number
* the day of the month
* the hour in 24-hour time
* the minute
* the second
* the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth

The dateItems does not change depending on the user's settings, so you can use it (or the seconds format) to store a date and time with a stack, in an invariant form that won't change.
Sunday is day 1 to Lc, not Monday as your system settings indicate.

Further, if you *do* set the useSystemDate to true, at the end of the handler it is in, it will convert back to it's default (false).

Re: dateItems show wrong day of the week

Posted: Sun Feb 09, 2025 2:02 pm
by Martin-HC
Thank you, bogs!