Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

 
alt

Daniel Nashed

 

ISO 8601 date format in Lotus Script

Daniel Nashed  2 October 2021 15:39:22

ISO 8601 date format isn't a new requirement but there isn't an implementation yet -- but there is an AHA idea.

Took me a moment to write conversion function. None of the date format functions helped.

The format string always appended the "GMT" string.


The tick is to use a NotesDateTime first to ensure you can convert into GMT.

In the next step LSGMTTime is important to convert the date to a normal Date (as a Variant ..).

Finally craft your own date string using the Format function for leading zeros..


-- Daniel


------------------


Update 3.9.2021: Lars came up with an easier way. I am not sure why I always had "GMT" added to my string when I tested with the Format function.

Here is a more simple way from Lars Berntrop-Bos:

Function ISO8601Date(dateTime As NotesDateTime) As String

  ISO8601Date = Format$(dateTime.LSGMTTime, "yyyy\-mm\-dd\Thh\:nn\:ss\Z")

End Function


Thanks Lars! This makes it more simple and this is why posting solutions make sense. Someone in the community might come up with a better solution! Cool thanks!

-- Daniel

------------------


Example:
2021-09-20T01:02:03Z

Function ISO8601Date (dateTime As NotesDateTime) As String


 Dim gmt As Variant

       
 gmt = dateTime.LSGMTTime

 ISO8601Date =  Format (Year (gmt),"0000") + "-" + Format (Month (gmt),"00") + "-" + Format (Day (gmt),"00") + "T" + Format (Hour (gmt),"00") + ":" + Format (Minute (gmt),"00") + ":" + Format (Second (gmt), "00") + "Z"

       
End Function


Links

    Archives


    • [HCL Domino]
    • [Domino on Linux]
    • [Nash!Com]
    • [Daniel Nashed]