UK Date script

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

UK Date script

Post by bsouthuk » Thu Jul 30, 2009 1:48 pm

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

Duncan
Posts: 13
Joined: Wed Feb 25, 2009 4:25 pm
Location: UK
Contact:

Post by Duncan » Thu Jul 30, 2009 2:47 pm

I think you need English rather than British.

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Post by bsouthuk » Thu Jul 30, 2009 2:59 pm

Sorry thats actually what I mean but it still displays the date in US format.

Why on earth is that?

SparkOut
Posts: 1763
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Jul 30, 2009 3:24 pm

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

Duncan
Posts: 13
Joined: Wed Feb 25, 2009 4:25 pm
Location: UK
Contact:

Post by Duncan » Thu Jul 30, 2009 3:27 pm

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.

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Post by bsouthuk » Thu Jul 30, 2009 3:29 pm

Brilliant - thats sorted it, thanks Duncan

Dan

gagsoft
Posts: 115
Joined: Sat Jun 29, 2013 7:56 pm

Re: UK Date script

Post by gagsoft » Thu Dec 28, 2017 1:18 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2669
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: UK Date script

Post by richmond62 » Thu Dec 28, 2017 1:33 pm

Interesting:

My iMac 10.7.5 currently set at Eastern European Time
and "Custom" Region:
Custom.png
gives me 28/12/17

which is near enough to what you choose to call "British" time.
Custom2.png
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.

MaxV
Posts: 1535
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: UK Date script

Post by MaxV » Thu Dec 28, 2017 1:52 pm

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") :D
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2669
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: UK Date script

Post by richmond62 » Thu Dec 28, 2017 3:34 pm

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.
dater.png
DATER.livecode.zip
(12.42 KiB) Downloaded 22 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2669
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: UK Date script

Post by richmond62 » Thu Dec 28, 2017 4:37 pm

Frankly, why I, or anyone else for that matter, didn't think of "that" years ago I just don't know. 8)
3cups.jpg
3cups.jpg (9.06 KiB) Viewed 952 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4561
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: UK Date script

Post by jacque » Thu Dec 28, 2017 8:01 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2669
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: UK Date script

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

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

Re: UK Date script

Post by bogs » Thu Dec 28, 2017 10:48 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4561
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: UK Date script

Post by jacque » Thu Dec 28, 2017 11:33 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Mac OS”