[Python-Dev] datetime nanosecond support
Christian Heimes
lists at cheimes.de
Wed Jul 25 15:59:03 CEST 2012
Am 25.07.2012 13:48, schrieb Antoine Pitrou:
>> I'd vote for two separate numbers, the first similar to JDN (Julian Day
>> Number [1]), the second for nanoseconds per day. 3600 * 1000000 fit
>> nicely into an unsigned 32bit int.
>
> But 24 * 3600 * 1e9 doesn't. Perhaps I didn't understand your proposal.
What the h... was I thinking? I confused nano with micro and forgot the
hours, how embarrassing. :(
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.
Christian
More information about the Python-Dev
mailing list