zopefoundation / DateTime

This package provides a DateTime data type, as known from Zope. Unless you need to communicate with Zope APIs, you're probably better off using Python's built-in datetime module.
Other
19 stars 25 forks source link

Bug report getting timezone #18

Closed terapyon closed 5 years ago

terapyon commented 5 years ago

I tried DateTime version 4.3 on Python 3.7. I found bug for DateTime parser.

>>> import sys
>>> sys.version
'3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) \n[Clang 6.0 (clang-600.0.57)]'
>>> from DateTime import DateTime
>>> DateTime("2019-11-9 10:00:00")
DateTime('2019/11/09 10:00:00 GMT+9')
>>> DateTime("2019-11-19 10:00:00")
DateTime('2019/11/19 10:00:00 GMT+0')
>>> DateTime("2019-11-09 10:00:00")
DateTime('2019/11/09 10:00:00 GMT+0')
perrinjerome commented 5 years ago

I guess this is not a bug, because it matches the documentation, but it's for sure a surprising behaviour.

https://github.com/zopefoundation/DateTime/blob/172afd3020eb197449067b1291426a0b351c90e0/src/DateTime/DateTime.txt#L103-L106

The first case ( 2019-11-9 10:00:00 ) does not match ISO 8601 format, but the later cases do.

See also https://sixfeetup.com/blog/zope-datetime-careful-with-that-dash-eugene

terapyon commented 5 years ago

I was mis understood parser format. I set "YYYY-MM-D", but this is wrong format.

Thank you for supporting @perrinjerome . I will close this issue.

perrinjerome commented 5 years ago

You're welcome. For the records, https://github.com/zopefoundation/DateTime/issues/5 and https://github.com/zopefoundation/DateTime/issues/6 were similar issues.