Random observations of a very experienced software artist.

Parsing an ISO 8601 Date with Lotusscript Split

John McCann  July 21 2010 12:00:00 PM
Domino, for all its "we conform to standards" hype a few years, doesn't support dates standards well, specifically ISO 8601 (wikipedia, ISO, or W3C) date formats.  What is worse, is that Domino has adopted Dojo as a "standard" which does all its date work in ISO 8601 format.   Since I am using Dojo, I had to write a routine to convert the ISO 8601 to NotesDateTime formats.  Since I had less than a week to do this, I decided to only support a realistic subset of the standard using the W3C note.  And, since I had made the error once (in generating ISO 8601 dates from Domino dates), I wanted to relax the requirement for leading zeros on the day, month, and hour.

So, rather than a positional parser, e.g. chars 6-7 designate month if 1 based origin counting, I recognized that I required special characters and could split the date string based on the special characters and then put it back together as dateserial and timeserial.  What I would have liked was a split function where I could specify multiple delimiters.   Though it is poorly documented, the lotusscript split function does not allow that.  You specify a delimiter string, not a string of delimiters.

And, I didn't want to get into the rather lengthy method of specifying array values one at a time.   So, I came up with the following:


where rstrDate is the date value passed as a string to the function;


Dim vntSplitVal        as Variant        ' get values here
Dim vntSplitDel        as Variant        ' get delimiters here

vntSplitVal = Split(Replace(rstrDate,Split("+/-/:/T/Z","/"),Split("!/!/!/!/!","/")), "!",-1,5)
vntSplitDel = FullTrim(Split(Replace(rstrDate,Split("0/1/2/3/4/5/6/7/8/9","/"),Split("!/!/!/!/!/!/!/!/!/!","/")),"!",-1,5))

vntSplitVal now contains the components that we could combine

functionName = DateSerial(vntSplitVal(1), vntSplitVal(2), vntSplitVal(3)) + TimeSerial(vntSplitVal(4), vntSplitVal(5), vntSplitVal(6))

Of course, the full routine adds a lot of validity checking (which is why the delimiters are also split) as well handling the Time Zone offset.