This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Neil Muller, andersjm, belopolsky, davidfraser, hodgestar, tebeka, vstinner, werneck
Date 2008-11-24.17:13:41
SpamBayes Score 1.7421414e-07
Marked as misclassified No
Message-id <1227546823.91.0.931359618478.issue2736@psf.upfronthosting.co.za>
In-reply-to
Content
Ooops, timestamp (c) is the *Mac* timestamp: seconds since the 1st 
january 1904.

> what is your conclusion?

Hum, it's maybe not possible to choose between integer and float. Why 
not supporting both? Example:
 - totimestamp()->int: truncate microseconds
 - totimestamp(microseconds=True)->float: with microseconds

Attached file (timestamp.py) is a module to import/export timestamp in 
all listed timestamp formats. It's written in pure Python.
----------------
>>> import timestamp
>>> from datetime import datetime
>>> now = datetime.now()
>>> now
datetime.datetime(2008, 11, 24, 18, 7, 50, 216762)

>>> timestamp.exportUnix(now)
1227550070
>>> timestamp.exportUnix(now, True)
1227550070.2167621
>>> timestamp.exportMac(now)
3310394870L
>>> timestamp.exportWin64(now)
128720236702167620L
>>> timestamp.exportUUID(now)
134468428702167620L

>>> timestamp.importMac(3310394870)
datetime.datetime(2008, 11, 24, 18, 7, 50)
>>> timestamp.importUnix(1227550070)
datetime.datetime(2008, 11, 24, 18, 7, 50)
>>> timestamp.importUnix(1227550070.2167621)
datetime.datetime(2008, 11, 24, 18, 7, 50, 216762)
----------------

It supports int and float types for import and export.
History
Date User Action Args
2008-11-24 17:13:44vstinnersetrecipients: + vstinner, tebeka, davidfraser, belopolsky, andersjm, werneck, hodgestar, Neil Muller
2008-11-24 17:13:43vstinnersetmessageid: <1227546823.91.0.931359618478.issue2736@psf.upfronthosting.co.za>
2008-11-24 17:13:43vstinnerlinkissue2736 messages
2008-11-24 17:13:42vstinnercreate