3.0.5

Date parsing and formatting

I have been having trouble defining a date format. I traced my first problem to the date parsing function, which initialises the xmlExpr and xmlOut variables as follows:

var xmlExpr = /^(....).(..).(..).(..).(..).(..)........(...).(..)/; 
var xmlOut = "$1/$2/$3 $4:$5:$6 GMT$7$8";


However, DateTime values in the xml extracted from an ADO record set are in the format CCYY-MM-DDThh:mm:ss, which complies with ISO 8061.

In order to correctly format the dates, I redefined xmlExpr and xmlOut as follows:

var xmlExpr = /^(....).(..).(..).(..).(..).(..)/; 
var xmlOut = "$2/$3/$1 $4:$5:$6";


This worked fine. However, my second problem was that some dates were being output as the previous day! I traced this problem also to the date formatting class, which tokenises based on UTC. For UK localisation, it therefore interpreted dates at midnight from late March to late November as being one hour ahead of UTC, deducted an hour and gave 11 o'clock at night on the previous day! Not what I wanted. I amended the tokenising to work on local time and all was OK.

Two suggestions, therefore, for a future version. First, amend the existing ISO8061 format processing, or create a new format, to parse dates with the CCYY-MM-DDThh:mm:ss format. Second, amend the existing tokenising, or define an additional set of tokens, to work on local time.

I should mention that I am using XP, IE6.0SP2, MDAC 2.8 and version 1.0.1 of the date formatting class from http://www.activewidgets.com/messages/1252-3.htm.

Finally, traditional, but sincere, congratulations on an excellent product. My only gripe is that the slim documentation has made learning the product an uphill climb. But once there, it exceeds expectations.
Paul Whiteley
December 10,

This topic is archived.

See also:


Back to support forum