Date comparisons, EU vs US vs rest of the world
Posted: 03 Nov 2012 12:41
In the past hours I tried very hard to write a code able to compare a date provided by the OS (read: styled by OS locale rules) with another "fixed" date, the latter in a fixed dd/mm/yyyy hh:nn:ss format.
This proves difficult because datediff() assumes inputs styled according to the locale rules, as well as formatdate().
Which means that in US running
swap days and months, even if they're already in the correct place.
Probably the whole problem can be solved with a long code rich in if-loops and gettoken, which would be something against my philosophy of compactness and linearity.
I was thinking about a formatdate function a little enhanced, maybe together with a variable that return how the OS styles the dates.
Something like
Of course I'm open to other, creative suggestions.
PS: the real application of this problem can be found at line #264 of the script published here, http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=8744
This proves difficult because datediff() assumes inputs styled according to the locale rules, as well as formatdate().
Which means that in US running
Code: Select all
formatdate("fixed date", "dd/mm/yyyy hh:nn:ss")Probably the whole problem can be solved with a long code rich in if-loops and gettoken, which would be something against my philosophy of compactness and linearity.
I was thinking about a formatdate function a little enhanced, maybe together with a variable that return how the OS styles the dates.
Something like
Code: Select all
<date style> --- dd/mm/yyyy in EU, mm/dd/yyyy in US, yyyy/mm/dd in Japan
formatdate("input date", "input format", "output format", "shift unit", "shift num")PS: the real application of this problem can be found at line #264 of the script published here, http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=8744