DateTime() changes timezone if passed a DateTime instance
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Fix Released
|
Undecided
|
Paul Winkler |
Bug Description
(note, this feature was added in response to #143073 )
It appears that if the argument to DateTime is a DateTime instance, its timezone gets set to the local timezone, regardless of the passed value.
I think this is wrong behavior. The docstring says "If the DateTime function is invoked with a single argument that is a DateTime instance, a copy of the passed object will be created." It doesn't say anything about the copy possibly having a different timezone...
To demonstrate, you need to experiment with timezones *other than your local zone*.
For example, I'm in US/Eastern, so I can demonstrate with US/Pacific.
>>> from DateTime import DateTime
>>> dt1 = DateTime(
>>> dt1.timezone()
'US/Pacific'
>>> DateTime(dt1) == dt1
True
>>> DateTime(
'US/Eastern'
Notice that the second datetime is in a different zone!
You can also see this in the various string representations:
>>> dt1.ISO8601()
'2001-01-
>>> DateTime(
'2001-01-
Fixed on branch svn://svn. zope.org/ repos/main/ Zope/branches/ slinkp- datetime- 200007
I'll bring this up on zope-dev; if nobody objects in the next few days, I'll commit to trunk, 2.11, 2.10, and 2.9.