isodate icon indicating copy to clipboard operation
isodate copied to clipboard

Wrong datetime return

Open vetal4444 opened this issue 9 years ago • 6 comments

In [1]: import isodate

In [2]: isodate.parse_datetime("04-05-2015T14:32:00Z-09:00") Out[2]: datetime.datetime(401, 1, 1, 14, 32, tzinfo=<isodate.tzinfo.Utc object at 0x7fd4b4c46080>)

vetal4444 avatar May 06 '15 16:05 vetal4444

Hi,

"04-05-2015T14:32:00Z-09:00" this is a malformed iso date string.

The order of year, month, day is incorrect, and you have two time zone specifications in it 'Z' and '-09:00'.

I'll try to let the parser raise an exception.

gweis avatar May 06 '15 19:05 gweis

Releated to #15

gweis avatar Jul 06 '17 02:07 gweis

Related- timezones don't seem to ever parse, except for the Z timezone specification. This is an example, tested against isodate 0.6.0:

>>> isodate.parse_datetime("2019-03-20T13:30:00-5:00")
datetime.datetime(2019, 3, 20, 13, 30)

This should be returning a non-naive datetime with tzinfo on it, but it returns a naive datetime anyway.

Not that it should matter but America/Chicago is the local timezone of the system.

Is this project still maintained @gweis?

estein-de avatar Mar 19 '19 23:03 estein-de

@estein-de This is malformed TZ spec. it should be "2019-03-20T13:30:00-05:00" (two digit hours in TZ spec. (so still related to #15)

Ad maintenance: It is still sort of maintained. There are a couple of issues I'd like to address, but I am a bit low on free time currently.

gweis avatar Mar 20 '19 02:03 gweis

Oh thanks , #15 does seem like what I want - because then I would know it was malformed, the scary part is invalid data being misinterpreted

estein-de avatar Mar 20 '19 17:03 estein-de

Can confirm, working fine with 2 digit hour

>>> isodate.parse_datetime("2019-03-20T13:30:00-05:00")
datetime.datetime(2019, 3, 20, 13, 30, tzinfo=<FixedOffset '-05:00'>)

estein-de avatar Mar 20 '19 17:03 estein-de