#1 2025-10-22 10:28:50

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 470

ParseTimeZone and ISO8601

Trying to parse string datetime values in ISO 8601 I noticed that:
- In values like 2025-10-21T21:43:08-12:00  the timezone is not parsed
- When I provide only the "-12:00" part in ParseTimeZone it returns false
- ParseTimeZone works and returns true with values like "-1200" which is not the standard ISO 8601

just for your info

Offline

#2 2025-10-22 18:24:14

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,247
Website

Re: ParseTimeZone and ISO8601

As far as I can tell, it is as expected within the mORMot documentation since almost 20 years.
Internal date/time are encoded as ISO-8601 without timezone, because it is required (by convention) to be always GMT/UTC between machines.
It may be not full ISO-8601 compatible (which prefers an explicit Z), but if you really need it, you can use the twoDateTimeWithZ/woDateTimeWithZSuffix, and it will append the expected ending Z.
Using a time zone is just a wrong approach for any serialization mechanism: the time zone should be handled in the UI level, according to the real computer local time.

ParseTimeZone() is not to be used with ISO-8601, but with standard human-readable HTTP dates like in TSynSystemTime.FromHttpDateBuffer.

Offline

#3 2025-10-22 18:34:53

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 470

Re: ParseTimeZone and ISO8601

@ab,  I full agree with you.
The mormot is a great framework and it can be used futher than just a rest framework
I come I across with a date coming from a project and I spend little time to see what happens. I just left this topic as a FYI
Thank you again for this great work

Offline

Board footer

Powered by FluxBB