Problem with date
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Problem with date
See the dictionary entry for "useSystemDate"
-
- Livecode Opensource Backer
- Posts: 10115
- Joined: Fri Feb 19, 2010 10:17 am
Re: Problem with date
USESYSTEMDATE is a LOCAL property!
-
- Livecode Opensource Backer
- Posts: 10115
- Joined: Fri Feb 19, 2010 10:17 am
Re: Problem with date
Right . . .
In a button setting it to false:
- -
It does noting, as advertised.
In a button setting it to true
- -
It DOES change the format, and also mucks around with the itemDelimiter.
What is hilarious about this is that when I was at school (in England) our History teacher would write the date 8/20/2025 (well, he wouldn't as that was 1975). and our Maths teacher would write it 8.20.2025 . . .
In a button setting it to false:
- -
It does noting, as advertised.
In a button setting it to true
- -
It DOES change the format, and also mucks around with the itemDelimiter.

What is hilarious about this is that when I was at school (in England) our History teacher would write the date 8/20/2025 (well, he wouldn't as that was 1975). and our Maths teacher would write it 8.20.2025 . . .
-
- Livecode Opensource Backer
- Posts: 10115
- Joined: Fri Feb 19, 2010 10:17 am
Re: Problem with date
And, in a global world better tools are needed:
- -
Robot says:
- -
- -
Robot says:
- -
scholars estimate that roughly 40-50 distinct calendar systems are still actively used today in some capacity
-
- VIP Livecode Opensource Backer
- Posts: 10053
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Problem with date
There must be something in those images I'm not noticing.
xTalks use a default date format internally for computational consistency, and through useSystemDate LC accesses the user's preference expressed in OS settings for display.
Under what circumstance is the user's preference wrong?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Problem with date
Hi Klaus,
Here is the code..
Here is the code..
Code: Select all
if fld "dateready" is 3 then
set the itemdelimiter to "/"
put word 1 of fld "startday" into sday
put word 1 of fld "startyr" into syr
put word 1 of fld "startmth" into smth
put sday & "/" & smth & "/" & syr into tdate
put sday & "/" & smth & "/" & syr into tdate2
convert tdate2 to seconds
#answer tdate2
#convert tdate2 to system date
#convert tdate2 to seconds
put tdate2 into fld "date3"
show fld "announce81"
put "The start date of the current business trading year is" & CR & tdate into fld "announce81"
convert the date to seconds
put it into date2
put it into fld "date2"
put fld "date2" - fld "date3" into fld "temp1"
put 60*60*24*365 into date4
put 60*60*24*365 into fld "date4"
if fld "temp1" > fld "date4" then
put "nogo" into fld "temp2"
end if
if fld "temp2" is "nogo" then
answer "That date is more than a year ago, so cannot refer to the current year. Try again"
hide fld "announce81"
put empty into fld "temp2"
put empty into fld "temp1"
put empty into fld "date2"
put empty into fld "date3"
put empty into fld "date4"
exit mouseup
end if
-
- Livecode Opensource Backer
- Posts: 10115
- Joined: Fri Feb 19, 2010 10:17 am
Re: Problem with date
Is it just me, or?
or, might that not be:
Code: Select all
fld "dateready" is 3 then
Code: Select all
fld "dateready" contains 3 then
Re: Problem with date
Just you I'm guessing,
as in
Code: Select all
fld "dateready" is 3
Code: Select all
fld "dateready" = 3
Re: Problem with date
HI all,
I think I finally got it figured with this code
THank you all, once again for everything.
I think I finally got it figured with this code
Code: Select all
if fld "dateready" is 3 then
set the itemdelimiter to "/"
put word 1 of fld "startday" into sday
put word 1 of fld "startyr" into syr
put word 1 of fld "startmth" into smth
put smth & "/" & sday & "/" & syr into tdate2
put sday & "/" & smth & "/" & syr into tdate
convert tdate from system date to long english date
convert tdate2 to seconds
put tdate2 into fld "date3"
show fld "announce81"
put "The start date of the current business trading year is" & CR & tdate into fld "announce81"
convert the date to seconds
put it into date2
put it into fld "date2"
put fld "date2" - fld "date3" into fld "temp1"
put 60*60*24*365 into date4
put 60*60*24*365 into fld "date4"
if fld "temp1" > fld "date4" then
put "nogo" into fld "temp2"
end if
if fld "temp2" is "nogo" then
answer "That date is more than a year ago, so cannot refer to the current year. Try again."titled field "fieldboxtitle" of cd "template1"
hide fld "announce81"
put empty into fld "temp2"
put empty into fld "temp1"
put empty into fld "date2"
put empty into fld "date3"
put empty into fld "date4"
exit mouseup
end if
if fld "temp1" < 0 then
answer "That date is in the future, so cannot be the start date of the current year. Try again."titled field "fieldboxtitle" of cd "template1"
hide fld "announce81"
put empty into fld "temp2"
put empty into fld "temp1"
put empty into fld "date2"
put empty into fld "date3"
put empty into fld "date4"
exit mouseup
end if
end if
Re: Problem with date
Code: Select all
...
convert tdate from system date to long english date
...

But you still did not tell us what country (with that system date) you are living in.
Re: Problem with date
Hi Klaus,
I am a native of the United Kingdom of GREAT (get that ?, GREAT) Britain. Not to be confused (under any circumstances - torture, political waffle) with the European Union. A free-born Englishman, travelled the Orient, Africa, the Middle East, and now safely back home, struggling with systemdates and my mobile phone. Back in the day, I was a field helicopter engineer, often in the remotest of locations, in jungles, deserts, oil platforms, and that most perilous space of all, VIP airport lounges - ferrying ministers of state.
I like Livecode, and this forum is most helpful. I hope the above entertains rather that offends.
I am a native of the United Kingdom of GREAT (get that ?, GREAT) Britain. Not to be confused (under any circumstances - torture, political waffle) with the European Union. A free-born Englishman, travelled the Orient, Africa, the Middle East, and now safely back home, struggling with systemdates and my mobile phone. Back in the day, I was a field helicopter engineer, often in the remotest of locations, in jungles, deserts, oil platforms, and that most perilous space of all, VIP airport lounges - ferrying ministers of state.
I like Livecode, and this forum is most helpful. I hope the above entertains rather that offends.
-
- Livecode Opensource Backer
- Posts: 10115
- Joined: Fri Feb 19, 2010 10:17 am
Re: Problem with date
I'd be a bit careful where you use that phrase.A free-born Englishman
Re: Problem with date
Using "set the useSystemDate to true" in a handler where dates are interpreted generally makes things a lot simpler.
Put one field on a card "fldDate" and get a user to put a date into it in the user's typically accepted format
In a button
Assuming you're not falling foul of the inability of LiveCode to interpret a date on Windows prior to the Unix epoch (not a "Windows" bug, it's a "LiveCode" bug) then a user in USA with default regional settings, and a user in UK with default regional settings will both receive the same report of the seconds, despite having input different formats.
The useSystemDate property is reset to default (false) at the end of the handler - you have to specifically set it every time you're in a new scope.
Also, malte's libDate library is still available viewtopic.php?f=16&t=15752#p79627 (github link at end of the thread
https://github.com/derbrill/libdate )
Put one field on a card "fldDate" and get a user to put a date into it in the user's typically accepted format
In a button
Code: Select all
on mouseUp
set the useSystemDate to true
put field "fldDate" into tDate
if tDate is not a date then
answer "The field contents do not match the date format according to the regional settings of this computer" -- or you're on Windows and the year you've input is prior to 1970, stupid, stupidly unforgiveable bug
else
convert tDate to seconds
answer tDate
end if
end mouseUp
The useSystemDate property is reset to default (false) at the end of the handler - you have to specifically set it every time you're in a new scope.
Also, malte's libDate library is still available viewtopic.php?f=16&t=15752#p79627 (github link at end of the thread
https://github.com/derbrill/libdate )