question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Z suffix (and general time zones) in ISO 8601 timestamps

See original GitHub issue

Super useful workaround: https://github.com/astropy/astropy/issues/8720#issuecomment-717599497

In https://github.com/astropy/astropy/issues/2203 we discussed allowing the Z suffix in ISO strings, which indicates that the time is in UTC, and that got resolved. However, there was a discussion in there about outputting the Z suffix when formatting times, which was not conclusive.

I’ve now run into a related problem while developing time series-related functionality - specifically, if I do:

In [3]: t = Time('2010-01-01 00:00:00', scale='utc')                                                                                                   

In [4]: t.isot                                                                                                                                          
Out[4]: '2010-01-01T00:00:00.000'

then pass the resulting string to other tools, if they conform to ISO 8601 they will interpret this string as a local time, not a UTC time. From ISO 8601:

The zone designator is empty if use is made of local time in accordance with 4.2.2.2 through 4.2.2.4, it is the UTC designator [Z] if use is made of UTC of day in accordance with 4.2.4 and it is the difference-component if use is made of local time and the difference from UTC in accordance with 4.2.5.2.

Technically speaking, the outputted time above is wrong because I explicitly stated it was in UTC and yet the format doesn’t include Z.

At the moment, I’m finding myself having to create a whole new array of times with the Z suffix, and it would be much nicer if we could include the time zone information by default. Even if we don’t have full support for arbitrary time zones, I feel like if the time is a UTC time we should be including Z as a special case.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
Cadaircommented, May 17, 2019

Always follow the standards 😉

1reaction
mhvkcommented, May 19, 2019

I think that we can, for now, just follow what we do for datetime, where we interpret timezones and allow them to be set on output, but do not store it in the Time instance. See http://docs.astropy.org/en/latest/time/index.html#timezones

Read more comments on GitHub >

github_iconTop Results From Across the Web

What do T and Z mean in timestamp format ? - LinkedIn
The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated ... The literal “Z” is actually part...
Read more >
ISO 8601 - Wikipedia
ISO 8601 is an international standard covering the worldwide exchange and communication of date and time-related data. ... with optional UTC offset; time...
Read more >
ISO 8601 date-time format combining 'Z' and offset of '+0000'
No, the Z is an offset-from-UTC so it should not be combined redundantly with a numerical offset of +00:00 or +0000 . ISO...
Read more >
RFC 3339 Date and Time on the Internet: Timestamps - IETF
Z A suffix which, when applied to a time, denotes a UTC offset...
Read more >
Date and Time Formats - W3C
ISO 8601 describes a large number of date/time formats. For example it defines Basic Format, without punctuation, and Extended Format, with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found