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.

1Tom Murphy  4/25/2011 11:37:05 AM  Parsing an ISO 8601 Date with Lotusscript Split

Great, thanks for this useful function. But shouldn't the last bit be

(",", not "+")

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

2John McCann  7/12/2011 8:19:00 PM  Parsing an ISO 8601 Date with Lotusscript Split

Thanks Tom, Great catch. My production code had already reflected the fix to that typo, i just hadn't got it back to the blog.

After I wrote my routine, I found that Domino does provide some ISO8601 date support. It is hidden away in the LotusScript webservices component in the lsxsd.lss file. My implementation provides certain advantages such as flexible lengths for day and month and support for partial timestamps, e.g., just hours and minutes. I don't support all the character specification of the timezones, e.g., EST, but my need was to transmit in Zulu aka GMT aka UCT aka British Time.

3iso 9000  9/29/2011 7:46:09 AM  iso 9000

Hey, very nice site. I came across this on Google, and I am stoked that I did. I will definately be coming back here more often. Wish I could add to the conversation and bring a bit more to the table, but am just taking in as much info as I can at the moment.

<a href="{ Link } title="iso 9000">iso 9000</a>