[Python-Dev] datetime nanosecond support

Charles Cazabon charlesc-lists-python-dev2 at pyropus.ca
Wed Jul 25 16:21:25 CEST 2012

Christian Heimes <lists at cheimes.de> wrote:
> days
> ----
> 32bit signed integer
> numbers of days since Jan 1, 1 AD in proleptic Gregorian calendar (aka
> modern civil calendar). That's Rata Die minus one day since it defines
> Jan 1, 1 AD as day 1. This allows days between year 5.8 Mio in the past
> and 5.8 Mio in the future ((1<<31) // 365.242 ~ 5879618).
> nanoseconds
> -----------
> 64bit signed or unsigned integer
> more than enough for nanosecond granularity (47bits), we could easily
> push it to pico seconds resolution (57bits) in the future.

An alternate strategy might be to use tai64/tai64n/tai64na, which can
represent any time over the course of a few hundred billion years to
second/nanosecond/attosecond, respectively.  They're well-defined, and there's
a fair bit of software that can use or manipulate dates in these formats.
tai64 is defined similar to propleptic Gregorian in that it uses an idealized
24*60*60 second day, etc.

Charles Cazabon
GPL'ed software available at:               http://pyropus.ca/software/

More information about the Python-Dev mailing list