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

Difference in GMT when creating DateTime object from string with "-" or "/" separators #2

Closed keul closed 10 years ago

keul commented 10 years ago

Issue found on DateTime 3.0 and also 2.12:

>>> from DateTime import DateTime
>>> DateTime('2014-03-17')
DateTime('2014/03/17 00:00:00 GMT+0')
>>> DateTime('2014/03/17')
DateTime('2014/03/17 00:00:00 GMT+1')

It seems that when using the - separator the date is always created in GMT +0 while using / returns the right GMT.

terapyon commented 10 years ago

I just checked on DateTime-3.0.3 (with Plone 4.3.2). I found the same result. (My local time is JST (GMT+9)

$ ./bin/zopepy

from DateTime import DateTime DateTime('2014-03-17') DateTime('2014/03/17 00:00:00 GMT+0') DateTime('2014/03/17') DateTime('2014/03/17 00:00:00 GMT+9')

tseaver commented 10 years ago

The choice to using UTC when parsing an ISO-conformant datetime is deliberate. I would say that the docs should point this out, with an example, in the section on the DateTime constructor.

mgedmin commented 10 years ago

ISO 8601 has special syntax for UTC: you append the letter Z to the end to the timestamp. Timestamps not ending in Z are assumed to be in local time.

Some countries have a national standard for expressing time that happens to match ISO-8859-1. Zope's decision to treat them as UTC baffles me. (I stopped using Zope 2 a while ago, so I don't really care; I can just add this to my mental list of reasons why nobody should be using Zope 2).