I just spent an inordinate amount of time trying to figure out how to work with dates in different country formats in LC. Though it seems rather simple and obvious now, the following are my 3 basic rules which you may want to tuck away for that eventual day when you are pulling your hair out over this issue:
1. To display the current date (the date) in the users native country format do this:
put the system date into field "x"
2. To use this date in a calculation:
You don't actually have to use the "system date" in your calculations. You
can use "the date" which is easier and faster: convert the date into seconds
If you must use the system date, see the next item.
3. To work with a date entered in the users native country format (assume input is into field x):
put field "x" into myvariable
convert myvariable from system date to (seconds, dateitems, etc)
In #3, because you are expecting the date to be entered in the users native country
format you have no option but to convert it from a system date into a date, seconds,
dateitems, etc format.
Hmmm... tried to post some results in tabular format but all attempts to do so were defeated by
this editor which does not appear to appreciate the beauty of tables. Anyway, its very cool how
transparent this becomes when you code in the above style... you get dramatically different
results in the US, UK and Canada and all using the same LC.
Have fun,
-- Mark
Working with dates
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Working with dates
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS