Date format...

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Date format...

Post by Traxgeek » Sat Sep 27, 2014 3:48 pm

Hi...
I ALWAYS struggle when it comes to the logic around taking and displaying different dates in different system/user formats (eg : US - MM/DD/YYYY or EU - DD/MM/YYYY)...

and, for the moment I'm struggling with this on my Android device... I must be missing something really simple but I just can't get my head around this...

Code: Select all

#TEST - START
   local TEST
   put the short system date into TEST
   convert TEST from short system date to dateitems
   answer the short system date & "  =  " & TEST
#TEST - STOP
When I run this on my Mac I get the same format (DD/MM/YYYY) as I have set in the regional settings : 27/09/2014 = 2014,9,27,0,0,0,7
When I run this on my Android (ICS) I get the Month and Date swapped... I also get the year reported as simply '14' (not the more usual 2014) : 9/27/14 = 2014,9,27,0,0,0,7 - Regardless of the date/time settings in the Config panel and the true/false of LC's 'useSystemDate' property...

So I then try :

Code: Select all

#TEST - START
   put "01" into nD
   put "02" into nM
   put "2000" into nY
   put nD & "/" & nM & "/" & nY into dDate
   put dDate into sItems
   put sItems into sItems
   answer dDate & "  =  " & sItems
#TEST - STOP
On my Mac I get : 01/02/2000 = 2000,2,1,0,0,0,3
On my Android I get : 01/02/2000 = 2000,1,2,0,0,0,1

What am I doing wrong please ? (I've tried setting the Android's Date/Time to be DD/MM/YYYY and / or MM/DD/YYYY - same results ) I'm doing something stupid.... what is it please....

Thanks peeps...
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Date format...

Post by newtronsols » Sat Sep 27, 2014 4:23 pm

You have to live with it and swap it around for UK Android.

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Date format... (SOLVED)

Post by Traxgeek » Sat Sep 27, 2014 4:40 pm

Thanks newtronsols.

Spend a good day on this Arrrrrggghhhhh ! Still - won't make the same mistake again... :D

Now just how to detect what the user is using... Normally, I auto-detect this in code but... now I guess I'll need to ask the user what format they 're using / want to use ?

OK... I'll work around it.

Thanks a million - both the putting me out of my misery and being sooooo quick about it. Owe you !
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Date format...

Post by Traxgeek » Sat Sep 27, 2014 4:51 pm

Sorry newtronsols,

One question - is this the same for iOS ? Or is iOS OK ? Can't test yet on iOS... Hoped you may be able to give me a 'heads up' so I know what to code now... Appreciate this is an Android forum tho... :oops:

Thanks a mil.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Date format...

Post by newtronsols » Sat Sep 27, 2014 6:33 pm

I can't test iOS.

Use something like:
#this is where user selects the date but it is similar to where you use the system date
mobilePickDate "date"
if the result <> "cancel" then
put the result into tdate
set the itemDelimiter to "/"
#uk format
put item 2 of tdate into tday
put item 1 of tdate into tmonth
put item 3 of tdate into tyear
put tday & "/" & tmonth & "/" & tyear into field "date"

obviously you'd need a way to check for country 'UK' - either user selection or some other complicated clever means - e.g. working out longitude/lattitude mobileCurrentLocation() and determining the country..etc.. or via a web browser - c/f http://stackoverflow.com/questions/1182 ... he-os-from

Post Reply