Page 1 of 1
UK Date script
Posted: Thu Jul 30, 2009 1:48 pm
by bsouthuk
Does anybody know how to tell revolution to reveal a date in british format? i.e day/month/year?
At the moment mine is set to USA format - month/day/year.
i have tried
Code: Select all
put the british date into field "date"
but that doesnt work.
Cheers
Daniel
Posted: Thu Jul 30, 2009 2:47 pm
by Duncan
I think you need English rather than British.
Posted: Thu Jul 30, 2009 2:59 pm
by bsouthuk
Sorry thats actually what I mean but it still displays the date in US format.
Why on earth is that?
Posted: Thu Jul 30, 2009 3:24 pm
by SparkOut
Unfortunately this is not a global setting - you will need to declare it in each handler where dates are being manipulated in the "local" view, but you can
Code: Select all
set the useSystemDate to true
put the short date into field "date"
and Rev will put the date format into the local view, as set by the user's system. It can cause a problem if you have international views, so it can be a good idea always to store dates in seconds or dateItems formats (or for storing in a database, convert to ISO formats first and handle appropriately on retrieval).
Posted: Thu Jul 30, 2009 3:27 pm
by Duncan
According to the dictionary Month/Day/Year is the English form:
A long English date looks like this: Thursday, June 22, 2000
An abbreviated English date looks like this: Thu, Jan 22, 2000
A short English date looks like this: 1/22/00
Code: Select all
put the system date into the field
uses the D/M/Y version on my UK based computer.
Posted: Thu Jul 30, 2009 3:29 pm
by bsouthuk
Brilliant - thats sorted it, thanks Duncan
Dan
Re: UK Date script
Posted: Thu Dec 28, 2017 1:18 pm
by PeterG
Hi Guys
Just played with the dates and got the following results:
At the moment I am using LiveCode 8.1.8
Set my Mac to South Africa. we use dd/mm/yyyy
using this script
put empty into field "Date"
set the useSystemDate to true
put the short date into field "Date"
produces 2017/12/28
Then I set the regional setting to UK with the same script and got exactly the same result 2017/12/28
Re: UK Date script
Posted: Thu Dec 28, 2017 1:33 pm
by richmond62
Interesting:
My iMac 10.7.5 currently set at Eastern European Time
and "Custom" Region:
gives me 28/12/17
which is near enough to what you choose to call "British" time.
You can muck around with these settings forever in Mac OS . . . and Revolution/LiveCode
being "dumb" in this respect will just read whatever the system dishes out.
Re: UK Date script
Posted: Thu Dec 28, 2017 1:52 pm
by MaxV
Hi folks,
I remember you that there is the free date library here:
https://github.com/derbrill/libdate
With a lot of functions ready to use for dates, and you a free to contribute. (Sign in, click fork, make your edits and push "pull request")

Re: UK Date script
Posted: Thu Dec 28, 2017 3:34 pm
by richmond62
Code: Select all
on mouseUp
put empty into fld "modDATE"
put empty into fld "origDATE"
set the useSystemDate to true
set the itemDelimiter to "/"
put the dateFormat into PHORMAT
switch (item 1 of PHORMAT)
case "%#d"
put (item 1 of the short date) into DEN
break
case "%#m"
put (item 1 of the short date) into MESETS
break
case "%Y"
put (item 1 of the short date) into GODINA
break
end switch
switch (item 2 of PHORMAT)
case "%#d"
put (item 2 of the short date) into DEN
break
case "%#m"
put (item 2 of the short date) into MESETS
break
case "%Y"
put (item 2 of the short date) into GODINA
break
end switch
switch (item 3 of PHORMAT)
case "%#d"
put (item 3 of the short date) into DEN
break
case "%#m"
put (item 3 of the short date) into MESETS
break
case "%Y"
put (item 3 of the short date) into GODINA
break
end switch
put GODINA && "/" && MESETS && "/" && DEN into fld "modDATE"
put the short date into fld "origDATE"
end mouseUp
Obviously you can muck around with the line:
Code: Select all
put GODINA && "/" && MESETS && "/" && DEN into fld "modDATE"
to reorder things to suit your needs.
Re: UK Date script
Posted: Thu Dec 28, 2017 4:37 pm
by richmond62
Frankly, why I, or anyone else for that matter, didn't think of "that" years ago I just don't know.

- 3cups.jpg (9.06 KiB) Viewed 11170 times
Re: UK Date script
Posted: Thu Dec 28, 2017 8:01 pm
by jacque
The systemDate uses the settings in the OS preferences for the date format. After changing the region, also check to make sure that the date format is what you expect.
If you omit the line in the handler that uses the system date, you'll always get the English date by default.
Re: UK Date script
Posted: Thu Dec 28, 2017 10:16 pm
by richmond62
The "thing" about my script is that if you don't know what your end-user's date format it it doesn't matter.
This could be useful if you want your standalone to "phone home" with a date, or set an expiry date
for a licence.
Re: UK Date script
Posted: Thu Dec 28, 2017 10:48 pm
by bogs
richmond62 wrote: ↑Thu Dec 28, 2017 10:16 pm
The "thing" about my script is that if you don't know what your end-user's date format it it doesn't matter.
If you were looking for specific formatting, regardless of the end users system, why wouldn't you just use the date() function? Seems like "put item 2, item 1, item 3 of the date" would be easier than anything else, once you settle on a format you want to grab from, internet, long, short, etc.
Re: UK Date script
Posted: Thu Dec 28, 2017 11:33 pm
by jacque
richmond62 wrote: ↑Thu Dec 28, 2017 10:16 pm
The "thing" about my script is that if you don't know what your end-user's date format it it doesn't matter.
This could be useful if you want your standalone to "phone home" with a date, or set an expiry date
for a licence.
If you don't know the user's date format, using the systemDate will display it as the user would expect. Then, if you later want a standard format for communication with other apps or a server script, you would specify the English date, dateItems, internet date, or any of the other date formats. You can also use the dateFormat for more granular control.
Date formats are very flexible and designed to cover the situation you described, so there's no need to write a script for it.
EDIT: Apologies, dateFormat is read-only. No wonder I always parse dateItems.