Problem with date

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

CAsba
Posts: 444
Joined: Fri Sep 30, 2022 12:11 pm

Problem with date

Post by CAsba » Wed Aug 20, 2025 12:54 pm

Hi again,
My euphoria in solving the last date problem was shortlived. I discovered by chance that the convert to seconds command was intermittently failing to work. I isolated the problem in a substack, consisting of two fields, field, and field2, and a button. The button code is

Code: Select all

convert fld "field" to seconds
convert fld "field2" to seconds
In fld "field" I typed 24/3/25 and in fld "field2" I typed 3/3/25.
Only fld "field2" converted.
Please try this and tell me if this failure is universal or, as usual, down to something I am doing wrong.

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem with date

Post by Klaus » Wed Aug 20, 2025 2:07 pm

I can reproduce this! No idea if this is a bug or a freature.

In the meantime use a variable and write it back after conversion:

Code: Select all

...
put fld "field" into tSecs1
convert tSecs1 to seconds
put tSecs1 into fld "field"
## Same for fld "field2"
...
Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: Problem with date

Post by dunbarx » Wed Aug 20, 2025 2:33 pm

CAsba, Klaus.

The "dates" in the two fields are of different formats. Of course they cannot be conceptually mixed in the simplistic way CAsba tried.


Craig

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem with date

Post by Klaus » Wed Aug 20, 2025 2:50 pm

Ah, yes, my fault!

@CAsba
When using "convert" you need to supply a VALID format.
If you don't specify a format, LC thinks you are using a ENGLISH date (mm/dd/yy)
and 24/3/25 is NOT, so it won't get converted.

I thought you already got a hint about SYSTEMDATE in another thread?


Best

Klaus

CAsba
Posts: 444
Joined: Fri Sep 30, 2022 12:11 pm

Re: Problem with date

Post by CAsba » Wed Aug 20, 2025 2:58 pm

Thinking about this, it occurred to me that maybe, to convert, the date to be converted should be in the american format. I'll try playing with that.

CAsba
Posts: 444
Joined: Fri Sep 30, 2022 12:11 pm

Re: Problem with date

Post by CAsba » Wed Aug 20, 2025 3:00 pm

Hi Klaus,
I didn't get your input until after I sent mine !
Two ships in the night..

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

Re: Problem with date

Post by richmond62 » Wed Aug 20, 2025 3:01 pm

ENGLISH date (mm/dd/yy)
That is an American date, and not an English one.

AND if you ask for the date:

Code: Select all

put the date
you will get whatever is the format of the end-user's computer.

If you do this:

Code: Select all

put the dateFormat
you will be able to use that to work out what format the end-user is using.

For instance, my system uses the European date format and returns:

%#d.%m.%y

Then you'll have to play various funny games depending on whether:

1. The month has 28,29,30, or 31 days.

2. Whether the preceding year had 365 or 366 days in it.
-
Screenshot 2025-08-20 at 17.10.01.png
Last edited by richmond62 on Wed Aug 20, 2025 3:11 pm, edited 1 time in total.

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem with date

Post by Klaus » Wed Aug 20, 2025 3:09 pm

And how does an ENGLISH date look like?

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

Re: Problem with date

Post by richmond62 » Wed Aug 20, 2025 3:14 pm

There is some confusion as today, in the English format is:

20/08/2025

while the American format is:

08/20/2025

But for some ODD reason:
-
Screenshot 2025-08-20 at 17.13.31.png
-
inwith LiveCode 'english' specifies the American date format. :roll:

viewtopic.php?t=21655

in a perfect world (?) one could do this sort of thing (pseudocode):

Code: Select all

set the dateFormat to "ukrainian"
Note: The english keyword is implemented internally as a property and appears in the propertyNames. However, it cannot be used as a property in an expression, nor with the set command.
Last edited by richmond62 on Wed Aug 20, 2025 3:19 pm, edited 1 time in total.

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem with date

Post by Klaus » Wed Aug 20, 2025 3:19 pm

AHA!
Thank you for the explanation, so I got it wrong the last 69 years! 8-)

CAsba
Posts: 444
Joined: Fri Sep 30, 2022 12:11 pm

Re: Problem with date

Post by CAsba » Wed Aug 20, 2025 3:25 pm

Hi Klaus,
I don't think I picked up a hint about systemdate in a previous thread..
I'm now trying to find how to change 24/3/25 into a systemdate (?) other than writing some complex script to move the dateitems of it to new positions.

CAsba
Posts: 444
Joined: Fri Sep 30, 2022 12:11 pm

Re: Problem with date

Post by CAsba » Wed Aug 20, 2025 3:30 pm

Klaus,
I forgot to say, the code you sent me didn't do it.

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem with date

Post by Klaus » Wed Aug 20, 2025 3:49 pm

CAsba wrote:
Wed Aug 20, 2025 3:30 pm
Klaus,
I forgot to say, the code you sent me didn't do it.
Yes, because we used an invalid (non english) date -> 24/3/25

Code: Select all

...
convert fld "field" FROM SYSTEM DATE to seconds
convert fld "field2" FROM SYSTEM DATE to seconds
...
Will work as long as there ARE in fact system dates in the fields.
What country are you living in?

And how did the date get into the field? Did your user enter it or are you using a script?
If the latter please show the script.

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

Re: Problem with date

Post by richmond62 » Wed Aug 20, 2025 3:50 pm

Code: Select all

on mouseUp
   put "1/1/08 3:06 AM" into theTime
   convert theTime to seconds
   put theTime
end mouseUp

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

Re: Problem with date

Post by richmond62 » Wed Aug 20, 2025 3:57 pm

Here's a fairly silly stack that will convert your system date to what LiveCode erroneously calls the 'English' date:
-
Screenshot 2025-08-20 at 17.55.27.png
Attachments
Seconder.livecode.zip
Stack.
(1.29 KiB) Downloaded 4 times

Post Reply