[egenix-users] Unexpected Behaviour of DateTimeFromTicks

Novin novin01 at gmail.com
Fri May 25 15:12:31 CEST 2007


I'm trying to round a date to the nearest hour. To do so I converted it to
a float using ticks(), rounded it then converted it back to a DateTime
object
using DateTimeFromTicks.

Unfortunately this didn't work as I expected on clock change days - see
below:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.8.1.rc3 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

  Welcome to pylab, a matplotlib-based Python environment.
  For more information, type 'help(pylab)'.

In [1]: import mx.DateTime

In [2]: mx.DateTime.__version__
Out[2]: '3.0.0'

In [3]: comdate = 35155.04167

In [4]: mxdate1 = mx.DateTime.DateTimeFromCOMDate(comdate)

In [5]: print mxdate1
1996-03-31 01:00:00.28

In [6]: mxdate2 = mx.DateTime.DateTimeFromTicks(mxdate1.ticks())

In [7]: mxdate1 == mxdate2
Out[7]: False

In [8]: print mxdate2
1996-03-31 00:00:00.28


Is this the expected behaviour? It seems a little un-intuitive to me!

NB: using .absvalues() and DateTimeFromAbsDateTime works as expected.

Rgds,
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman-archives/egenix-users/attachments/20070525/1be778f6/attachment.htm


More information about the egenix-users mailing list