My API is representing time to clients using ISO 8601. We have a feature where we want to display which timezone it was from. By purely storing the timezone offset, we are loosing track of that detail.
ie, Utah and Arizona observe MST -06:00
for half of the year and Utah switches to MDT -07:00
for the other half. Our current solution is to determine if the date was during daylight savings and to use *DT
timezones during and *ST
otherwise, but ISO 8601 dates from Arizona would result in Pacific Daylight Time.
Is there a way to specify whether daylight savings is being observed in an ISO 8601 format? Like 2016-01-11T13:00:04Z DST0
or something similar?
The ISO 8601 standard defines an internationally recognized format for representing dates and times. For times, they are expressed with the notation hours-minutes-seconds.In the case of dates, the format is year-month-day.This basic format enables the numbers to be written directly after another.
ISO 8601-2:2019 defines a set of standardised extensions to the ISO 8601 date and time formats. The EDTF is given as an example of a profile of ISO 8601. Some of its features are: Uncertain and approximate qualifiers, '?' and '~', as well as their combined used, '%'; they can be applied to the whole date or to individual components.
The above will respond with output that looks as follows, which we can see has the correct ISO 8601 offset for Europe/Madrid for October 12th when daylight savings is in effect. As expected, the field my_time shows an offset of +02:00 .
For other time offsets see List of UTC time offsets. To represent a negative offset, ISO 8601 specifies using either a hyphen–minus or a minus sign character. If the interchange character set is limited and does not have a minus sign character, then the hyphen–minus should be used.
ISO 8601 glides quite smoothly (and misleadingly) between the terms "Time Zone" and "UTC Offset".
For the purpose of referencing a globally unique moment, a representation like "Thh:mm:ssZ+01:00" works perfectly in the sense that:
If you want to convey, in addition, the originator's locality then a suitable location field can be appended outside of the 8601 structure. There is no need to include location in a time field.
Personally, I'd like to see "Time Zone" banished from ISO 8601.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With