[Numpy-discussion] datetime64 1970 issue

Zachary Ploskey zploskey at gmail.com
Tue Apr 16 23:23:15 EDT 2013


The problem does not appear to exist on Linux with numpy version 1.6.2.

In [1]: import numpy as np

In [2]: np.datetime64('1970-01-01') - np.datetime64('1969-12-31')
Out[2]: 1 day, 0:00:00

In [3]: np.datetime64('1970-01-01 00') - np.datetime64('1969-12-31 00')
Out[3]: 1 day, 0:00:00

In [4]: np.__version__
Out[4]: '1.6.2'

Zach


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

> On Tue, Apr 16, 2013 at 4:55 PM, Bob Nnamtrop <bob.nnamtrop at 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')
>
> In [4]: np.__version__
> Out[4]: '1.7.1'
>
>
> We need to look into the sources to see what is going on.
>
> Ondrej
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130416/e9d896dc/attachment.html>


More information about the NumPy-Discussion mailing list