dateItems show wrong day of the week

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

dateItems show wrong day of the week

Post by Martin-HC » 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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: dateItems show wrong day of the week

Post by richmond62 » Sat Feb 08, 2025 4:44 pm

The Jewish week starts on Saturday night as soon as it gets dark. 8)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: dateItems show wrong day of the week

Post by FourthWorld » Sat Feb 08, 2025 5:42 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: dateItems show wrong day of the week

Post by bogs » Sun Feb 09, 2025 11:19 am

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).
Image

Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

Re: dateItems show wrong day of the week

Post by Martin-HC » Sun Feb 09, 2025 2:02 pm

Thank you, bogs!

Post Reply