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.
DateTime(0).equalTo(None) behaviour is different between DateTime 2 and DateTime 4+.
With DateTime 2
>>> from DateTime import DateTime
>>> DateTime(0).equalTo(None)
False
With DateTime 4+
>>> from DateTime import DateTime
>>> DateTime(0).equalTo(None)
True
It is caused by commit b9ddd8b9f9c8ba89fcab749a1871871706e7c2c0 where equalTo(None) is treated like equalTo(0) as 'further py3k work' (and same for greaterThanEqualTo and lessThanEqualTo). But if the intention is to accept comparing with None like Python 2, None is always the first in Python 2 sort, thus the implementation should be rather the following.
def equalTo(self, t):
if t is None:
return False # instead of 't = 0'
...
def greaterThanEqualTo(self, t):
if t is None:
return True # instead of 't = 0'
...
def lessThanEqualTo(self, t):
if t is None:
return False # instead of 't = 0'
...
For your reference, the interface docstring is the following, where I see no reason to treat None as DateTime(0)
Compare this DateTime object to another DateTime object OR
a floating point number such as that which is returned by the
python time module. Returns true if the object represents a
date/time equal to the specified DateTime or time module style
time. Revised to give more correct results through comparison
of long integer milliseconds.
BUG/PROBLEM REPORT / FEATURE REQUEST
DateTime(0).equalTo(None)
behaviour is different between DateTime 2 and DateTime 4+.With DateTime 2
With DateTime 4+
It is caused by commit b9ddd8b9f9c8ba89fcab749a1871871706e7c2c0 where
equalTo(None)
is treated likeequalTo(0)
as 'further py3k work' (and same forgreaterThanEqualTo
andlessThanEqualTo
). But if the intention is to accept comparing with None like Python 2, None is always the first in Python 2 sort, thus the implementation should be rather the following.For your reference, the interface docstring is the following, where I see no reason to treat None as
DateTime(0)
What do you think ?