Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ISO 8601 with Daylight Savings

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?

like image 353
bradynpoulsen Avatar asked Jan 11 '16 20:01

bradynpoulsen


People also ask

What is the ISO 8601 format for times?

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.

What is the ISO 8601 EDTF?

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.

What is the ISO 8601 offset for Europe/Madrid for October 12th?

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 .

How do you write negative time offset in ISO 8601?

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.


1 Answers

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:

  • it designates a unique point on the UTC scale,
  • it is agnostic whether the originator is located in Z+01, or in Z+00 during DST.

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.

like image 82
Paul White Avatar answered Dec 14 '22 23:12

Paul White