[Python-3000] __format__ and datetime
skip at pobox.com
skip at pobox.com
Tue Sep 11 16:33:03 CEST 2007
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"?
Skip
More information about the Python-3000
mailing list