[Python-3000] format and datetime (original) (raw)
Eric Smith eric+python-dev at trueblade.com
Mon Sep 10 17:31:23 CEST 2007
- Previous message: [Python-3000] __format__ and datetime
- Next message: [Python-3000] __format__ and datetime
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Eric Smith wrote:
Martin v. Löwis wrote:
I have a patch to add format to datetime.time, .date, and .datetime. For non-empty formatspec's, I just pass on to .strftime. For empty formatspec's, it returns str(self).
I think this is the only reasonable interpretation of formatspec's for datetime. Does anyone think otherwise? Can you please show an example of how it would look like? >>> import datetime >>> format(datetime.datetime.now(), 'date: %Y-%m-%d time:%H:%M:%s') 'date: 2007-09-10 time:11:15:1189437339' >>> format(datetime.datetime.now(), '') '2007-09-10T11:15:51.329639'
Oops, that should have been '%S':
format(datetime.datetime.now(), 'date: %Y-%m-%d time:%H:%M:%S') 'date: 2007-09-10 time:11:28:12'
I'm not sure what strftime does with '%s', I don't see it documented.
datetime.datetime.now().strftime('%s') '1189438155'
- Previous message: [Python-3000] __format__ and datetime
- Next message: [Python-3000] __format__ and datetime
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]