Problem with dateItems (Day of the Week)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
pink
Posts: 285
Joined: Wed Mar 12, 2014 6:18 pm

Problem with dateItems (Day of the Week)

Post by pink »

I have a program that converts a timestamp in seconds to dateItems, and then uses item #7 of date items to determine whether it is a weekday or a weekend. The number does not seem to be coming up correctly.

When I convert to dateItems, the date and time appear correctly for the time zone I am currently in, but the day of the week seems to be off. Today for example is Tuesday, but if I take the seconds right now (1443563834) and convert to dateItems I get: 2015,9,29,17,57,14,3

Date is correct, time is correct. According to the dictionary, the number for day of the week should be "2" but I am getting "3".

Am I missing something here?

From the dictionary:
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 Monday is day 1, Tuesday is day 2, and so forth
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: Problem with dateItems (Day of the Week)

Post by dunbarx »

Hi.

I have always relied on the fact that today, Tuesday, is #3 in item 7 of the dateItems. And so on...

The dictionary entry is the Bizarro version.

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

Re: Problem with dateItems (Day of the Week)

Post by FourthWorld »

Has this documentation error been submitted to the bug queue?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: Problem with dateItems (Day of the Week)

Post by dunbarx »

I just actually looked in the dictionary. V, 6.7:

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

What version are you looking at?

Craig
pink
Posts: 285
Joined: Wed Mar 12, 2014 6:18 pm

Re: Problem with dateItems (Day of the Week)

Post by pink »

I'm using 7.1, but I started writing this program back with 7.0.3, it's always said that...

however, when I look at the dictionary entry for "convert" it says the following:
Comments:
If the dateAndTime is a container, the converted date and time is placed in the container, replacing the previous contents. If the dateAndTime is a string, the converted date and time is placed in the it variable.

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
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Problem with dateItems (Day of the Week)

Post by bn »

Hi,
I just looked it up and this documentation error was introduced in 6.7.3, in 6.7.2 the dictionary says day 1 of the week Sunday.

DateItems for Hypercard and LC always started the week on Sunday as it is custom in the USA.

The ISO Week has Monday as day 1. It is used in many parts of the world.

That is probably where the mix-up comes from.

Kind regards
Bernd
pink
Posts: 285
Joined: Wed Mar 12, 2014 6:18 pm

Re: Problem with dateItems (Day of the Week)

Post by pink »

this is really rather odd... I switched to a Windows computer, and the dictionary entry for dateItems is correct, but on all of my Macs, the entry is incorrect

anyhow, I'm submitting the bug report
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know
pink
Posts: 285
Joined: Wed Mar 12, 2014 6:18 pm

Re: Problem with dateItems (Day of the Week)

Post by pink »

it's incorrect on the web version of the dictionary too:

https://livecode.com/resources/api/#liv ... /dateitems
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Problem with dateItems (Day of the Week)

Post by FourthWorld »

What's the bug report number?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
pink
Posts: 285
Joined: Wed Mar 12, 2014 6:18 pm

Re: Problem with dateItems (Day of the Week)

Post by pink »

Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know
Post Reply