[Python-3000] format and datetime (original) (raw)

Guido van Rossum guido at python.org
Tue Sep 11 19:46:12 CEST 2007


On 9/11/07, skip at pobox.com <skip at pobox.com> wrote:

Skip> I would like to see an analog to %S which preserves fractions of a Skip> second as the default formatting for time and datetime objects Skip> does: Skip> >>> print(now) Skip> 2007-09-10 22:07:53.654774 Guido> Right. It's odd that there's nothing explicit that exactly Guido> produces the default. (Though floats have this issue too -- I Guido> wish it could be fixed there too.) Looking at the libref doc for time.strftime and the strftime(3) man pages on Solaris 10, Mac OS X and CentOS 4, I see that %f is unused ("f" is mnemonic for "fractions" of a second). Maybe after a little more investigation and not endless amounts of discussion this could be added to Python as the way to represent the fractions of seconds as an int representing microseconds. For example, the above example could be specified by %Y-%m-%d %H:%M:%S.%f Thinking about future advances in timekeeping, is microseconds too short? Maybe "%N" for "nanoseconds"?

No, the datetime module is explicitly defined to use microseconds. I don't expect there to be a practical use for nanoseconds (even microseconds are doubtful, but useful since one might want unique timestamps for more than 1000 events per second).

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-3000 mailing list