[Datetime-SIG] Drop datetime's offset restrictions?

Chris Barker chris.barker at noaa.gov
Wed Aug 12 22:44:05 CEST 2015

On Wed, Aug 12, 2015 at 9:05 AM, Alexander Belopolsky <
alexander.belopolsky at gmail.com> wrote:

> On Wed, Aug 12, 2015 at 11:37 AM, Chris Barker - NOAA Federal
> <chris.barker at noaa.gov> wrote:
> >> Whaddya think?  Continue nagging people for no reason at all, or let
> >> freedom bloom? ;-)
> >
> > As long as we're poking around in datetime, I say let freedom bloom!
> +0, but will be +1 if someone comes up with a specific proposal on how
> printing and parsing of
> extended precision timezones will work.
> See e.g., <http://bugs.python.org/issue15873>.

I'm a bit confused on what one has to do with the other?

Or is this about the fact that ISO 8601 seems to specify that the offset be
defined as:


so no room for seconds? Though it's seems the obvious extension is to
simply add the seconds:


Not that parsing of ISO 8601 is not a great idea to have in datetime. I've
often wondered why it isn't there.

BTW,  numpy's datetime64 does have it, and it's more or less the standard
way to create one. No idea what it does if you try to pass in an offset
with seconds... -- yes, I do, not hard to check:

In [54]: np.datetime64('2015-08-03T13:12:11-07:00:13')
ValueError                                Traceback (most recent call last)
<ipython-input-54-da564c1b4acf> in <module>()
----> 1 np.datetime64('2015-08-03T13:12:11-07:00:13')

ValueError: Error parsing datetime string "2015-08-03T13:12:11-07:00:13" at
position 25

The problem I see with ISO 8601 is that (AFAICT) there is no way to specify
a time zone -- only a UTC offset.

and offsets are not unique.

So if someone wants to create a datetime object from an ISO 8601 string,
they have two options:

 * The string does not contain an offset -- they should get a naive datetime

 * The string does contain an offset -- they have to get a datetime with a
UTC tzinfo object, with the offset having been applied.

Is there any issue here other than someone needs to find or write the code
and persuade everyone that it's clean an maintainable enough for the stdlib?



Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150812/e3afb8e3/attachment.html>

More information about the Datetime-SIG mailing list