[Numpy-discussion] datetime64 1970 issue

Benjamin Root ben.root@ou....
Tue Apr 16 19:45:11 CDT 2013


On Tue, Apr 16, 2013 at 7:45 PM, Ondřej Čertík <ondrej.certik@gmail.com>wrote:

> On Tue, Apr 16, 2013 at 4:55 PM, Bob Nnamtrop <bob.nnamtrop@gmail.com>
> wrote:
> > 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?
>
> Indeed, this looks like a bug, I can reproduce it on linux as well:
>
> In [1]: import numpy as np
>
> In [2]: np.datetime64('1970-01-01') - np.datetime64('1969-12-31')
> Out[2]: numpy.timedelta64(1,'D')
>
> In [3]: np.datetime64('1970-01-01 00') - np.datetime64('1969-12-31 00')
> Out[3]: numpy.timedelta64(31,'h')
>
>
Maybe, maybe not... were you alive then?  For all we know, Charles and co.
were partying an extra 7 hours every day back then?

Just sayin'

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130416/932cf82a/attachment.html 


More information about the NumPy-Discussion mailing list