[issue37962] Improve ISO 8601 timezone support in the datetime.fromisoformat() method

2019-08-27 Thread Zeth


Zeth  added the comment:

Did you read the attached PR? For three lines longer, the method becomes more 
generally useful now.

As pointed out in the other thread that you pointed to, Javascript can parse 
Python's seralised datetime object but Python cannot parse Javascript's due to 
the fact that you don't want to.

That other thread points to a third thread that starts in 2012 so it seems that 
you really think that is a feature rather than a bug.

The name of the method is fromisoformat, not "parse our internal home made 
format". The line in the documentation seems a bit weird to me to be honest. It 
is saying that we could make it generally useful for you user but we don't want 
to.

The reply to this bug, "use the dateutil.parser.isoparse that I maintain 
instead" is beside the point, we are talking about the standard library one. 
Why not put that in the standard library then if it can actually parse iso 8601 
format?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37962] Improve ISO 8601 timezone support in the datetime.fromisoformat() method

2019-08-27 Thread Paul Ganssle


Paul Ganssle  added the comment:

This is a duplicate of #35829.

The reason that 'Z' is not supported is that `fromisoformat()` is not a general 
ISO 8601 parser, but rather is intended to be the inverse of `isoformat()`. See 
the documentation here: 
https://docs.python.org/dev/library/datetime.html#datetime.datetime.fromisoformat

The current state of #35829 is that expanding to support all of ISO 8601 is an 
option, but determining the scope an the API are a bit tricky. ISO 8601 is more 
complicated than most people think.

In the meantime, `dateutil.parser.isoparse` is intentionally scoped to parse 
all valid ISO 8601 datetimes.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> datetime: parse "Z" timezone suffix in fromisoformat()
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37962] Improve ISO 8601 timezone support in the datetime.fromisoformat() method

2019-08-27 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +belopolsky, p-ganssle

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37962] Improve ISO 8601 timezone support in the datetime.fromisoformat() method

2019-08-27 Thread Zeth


New submission from Zeth :

The datetime.datetime.fromisoformat() method unnecessarily rejects datetime 
strings that are valid under ISO 8601 if timezone uses the UTC  designator or 
it only has hours.

In ISO 8601, section 4.2.5.1: "When it is required to indicate the difference 
between local time and UTC of day, the representation of the difference can be 
expressed in hours and minutes, or hours only."

And Section 4.2.4, UTC shall be expressed "by the UTC designator [Z]".

A key use case of the latter is being able to parse JavaScript Date objects 
(e.g. dates that have come from a web frontend or a JSON document). This 
considerably improves the usefulness of the datetime.fromisoformat method.

--
messages: 350630
nosy: zeth
priority: normal
pull_requests: 15224
severity: normal
status: open
title: Improve ISO 8601 timezone support in the datetime.fromisoformat() method

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com