[Numpy-discussion] datetime64 1970 issue

Bob Nnamtrop bob.nnamtrop@gmail....
Tue Apr 16 17:55:53 CDT 2013


I am curious if others have noticed an issue with datetime64 at the
beginning of 1970. First:

In [144]: (np.datetime64('1970-01-01') - np.datetime64('1969-12-31'))
Out[144]: numpy.timedelta64(1,'D')

OK this look fine, they are one day apart. But look at this:

In [145]: (np.datetime64('1970-01-01 00') - np.datetime64('1969-12-31 00'))
Out[145]: numpy.timedelta64(31,'h')

Hmmm, seems like there are 7 extra hours? Am I missing something? I don't
see this at any other year. This discontinuity makes it hard to use the
datetime64 object without special adjustment in ones code. I assume this a
bug?

Thanks,
Bob

ps I'm using the most recent anaconda release on mac os x 10.6.8 which
includes numpy 1.7.0.

pss It would be most handy if datetime64 had a constructor of the form
np.datetime64(year,month,day,hour,min,sec) where these inputs were numpy
arrays and the output would have the same shape as the input arrays (but be
of type datetime64). The hour,min,sec would be optional. Scalar inputs
would be broadcast to the size of the array inputs, etc. Maybe this is a
topic for another post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130416/9f57069c/attachment.html 


More information about the NumPy-Discussion mailing list