clock scan does not handle all ISO 8601 time formats
Closed / Fixed1075433fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-11-29 18:08:54
The man pages for clock scan command implies that you
can read a ISO 8601 point-in-time specifications. I
looked at the specification and examples from ,
http://www.w3.org/TR/NOTE-datetime , and find that
not all case are able to be parsed (in Tcl 8.4.8).
See test the results below:
Year:
# YYYY (eg 1997)
% clock format [clock scan 1997]
unable to convert date-time string "1997"
Year and month:
# YYYY-MM (eg 1997-07)
% clock format [clock scan 1997-07]
unable to convert date-time string "1997-07"
Complete date:
# YYYY-MM-DD (eg 1997-07-16)
% clock format [clock scan 1997-07-16]
Wed Jul 16 12:00:00 AM Eastern Daylight Time 1997
Complete date plus hours and minutes:
# YYYY-MM-DDThh:mmTZD (eg 1997-07-
16T19:20+01:00)
% clock format [clock scan 1997-07-16T19:20+01:00]
unable to convert date-time string "1997-07-
16T19:20+01:00"
# but if we remove the time zone offset it works but is
one hour to fast!!!
% clock format [clock scan 1997-07-16T19:20]
Wed Jul 16 8:20:00 AM Eastern Daylight Time 1997
# removing the T gives us the correct time ?? strange
% clock format [clock scan "1997-07-16 19:20"]
Wed Jul 16 7:20:00 PM Eastern Daylight Time 1997
# also if we remove the dashes and leave the T
% clock format [clock scan "19970716T19:20:00"]
Wed Jul 16 7:20:00 PM Eastern Daylight Time 1997
Complete date plus hours, minutes and seconds:
# YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-
16T19:20:30+01:00)
% clock format [clock scan 1997-07-
16T19:20:30+01:00]
unable to convert date-time string "1997-07-
16T19:20:30+01:00"
Complete date plus hours, minutes, seconds and a
decimal fraction of a second
# YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-
16T19:20:30.45+01:00)
% clock format [clock scan 1997-07-
16T19:20:30.45+01:00]
unable to convert date-time string "1997-07-
16T19:20:30.45+01:00"
where:
YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT
allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction
of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)
Mike Jacobson
[email protected]
dgp Ticket [1075433fff]: 1 change
[History diff]2004-11-30 01:32:08
dgp Ticket [1075433fff]: 1 change
[History diff]2004-11-30 01:32:09
kennykbplain2004-11-30 02:39:32
Logged In: YES user_id=99768 The man page has always lied about ISO8601 compliance. In fact, YYYYMMDDTHHMMSS and YYMMDDTHHMMSS are the only ISO8601 formats that free-form [clock scan] recognizes. I do *not* plan to add formats to free-form [clock scan], because all the ambiguity in the parsing is a nightmare already, and each new format compounds the problem. Instead, let me refer you to the Wiki page: http://wiki.tcl.tk/13094 where I discuss the planned approach in 8.5 to recognizing a broader variety of ISO8601 formats. I welcome comments, there or here.
kennykb Ticket [1075433fff]: 1 change
[History diff]2004-11-30 02:39:54
kennykbplain2004-12-13 22:54:37
Logged In: YES user_id=99768 Requested documentation made on both the trunk and the 8.4 branch. See http://wiki.tcl.tk/13094 for an approach to scanning ISO8601 dates and times using the 8.5 facilities.
Log in (anonymous is fine) to add a comment.