Z suffix (and general time zones) in ISO 8601 timestamps
See original GitHub issueSuper 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:
- Created 4 years ago
- Reactions:2
- Comments:12 (12 by maintainers)
Top GitHub Comments
Always follow the standards 😉
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 theTime
instance. See http://docs.astropy.org/en/latest/time/index.html#timezones