Menu

#4 Ambiguity in some date/time functions

open
nobody
None
5
2002-10-01
2002-10-01
A.H. Banen
No

Ambiguity build into some date and time functions

Summary: The output of system.createdate$ and
system.floattodate can become ambiguous based on
locale setting in Windows.
Either force their output to an extended universal
date/time format (i.e. "CCYY-MM-DD hh:mm:ss") or
allow for these functions as an extra parameter a
string containing date/time formatting symbols.

There is an ambiguity build into certain functions in
Dialect that produce a date and/or time string.
These functions are the system.createdate$ and
system.floatetodate functions. System.createdate$
and system.floatetodate produce an output based on
the _local country settings_ for time and date.
E.g. when a country uses a time setting like u:mm:ss
(specified in symbols used by Windows) without
specifying AM/PM sysmbols this produces a time part
in the output string that is ambiguous (both e.g.
1:30:01 and 13:30:01 will become formatted as
1:30:01). The problem with time formatting is not very
severe as probably most countries will useeither a 24
hour display or a 12 hour display with AM/PM
symbols; but the user could have overridden these
settings.
The problem with formatting dates is more severe. A
good many users still may use a date formatting like d-
M-jj (again symbols used by Windows, where d stands
for day, M for month and jj for the last to numbers of a
year [E.g. 1-10-2002 will become formatted as 1-10-
02]).
The local settings for date and time output are used
by system.createdate$ and system.floatdate thus
producing for some users ambiguous outputs (e.g.
what year would be 1-10-02? It could be 1-10-2002
but also 1-10-1902 or 1-10-2102...)
Neither system.createdate$ nor system.floattodate
offer the user/programmer the possibility to override
the output formatting like the core functions date$ and
time offer.
This means that programs that use
system.createdate$ and/or system.floattodate have a
build-in flaw that may lead to errors when used in
different locales.

There are two possibilities to solve this problem.
One would be to use a default output for
system.createdate$ and system.floattodate based on
the format for universal time e.g. the extended
universal date time format "CCYY-MM-DDThh:mm:ss"
which would produce for October 1st, 2002,
14:08:10 hours a string like "2002-10-1T14:08:10" (
note the separator 'T' between date and time, in
Dialect for compatibility system.parsetime this symbol
should be replaced by a space ' '). Users that would
need specific formatting could use the
system.datetimepart functions with either 'formatdate
or 'formattime and a string containing formatting
symbols.
An alternative would be to allow formatting of the
output of system.createdate$ and system.floattodate
directly by allowing the user to specify a formatting
string (like the ones used with system.datetimepart ) .

André

Universal date/time formatting:
http://www.lise.jp/datetime.html

Discussion


Log in to post a comment.

MongoDB Logo MongoDB