Improve pattern for timestamp values #35
Replies: 2 comments 4 replies
-
Hi Anders, You're absolutely right, that is the pattern. Of the three patterns you showed that match (click here for live test):
For #3, I will cut a bug issue, so we can fix this, hopefully for the next schema update, or soon thereafter. For #1 I will cut an issue for internal discussion. I agree with your point that the By the way, loved your website and cogent thoughts on the topic there. |
Beta Was this translation helpful? Give feedback.
-
@epursimuove, we recently merged a bug fix to the schema |
Beta Was this translation helpful? Give feedback.
-
Great initiative with this OvertureMaps project!
One thing that I noted is about how timestamps are handled within the Schema Reference (for example the
updateTime
property in https://docs.overturemaps.org/reference/places/place).The current pattern for these timestamps seems to be defined as
^[1-9]\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z|[-+]\d{2}:\d{2})?$
which I think can be improved, since this format may be too complex and also will let invalid "timestamp" values through if leaving the pattern as is.
When testing the strings
2023-02-22T23:55:01-08:00
and2023-02-22T23:55:01Z
they are both matching the pattern, which may be okay. The string2023-02-22T23:55:01
is also matching, which I think is not okay since this is actually a local datetime value and NOT an actual timestamp.My suggestion
If there are no requirements to actually support different time zones for these timestamps, I would argue that it is way better to have a pattern like
^[1-9]\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$
which will only match
2023-02-22T23:55:01Z
(the one using the UTC timezone) of the three examples from above.Most often there are no (good) requirements to support different time zones when you want to handle a timestamp.
My detailed arguments about how to handle timestamps in general and the difference between timestamp and local datetime can be found here: https://anders.nemonisimors.com/timestamps.php
Beta Was this translation helpful? Give feedback.
All reactions