[Python-Dev] datetime and timedelta enhancement (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Sat Nov 15 02:01:42 CET 2008
- Previous message: [Python-Dev] datetime and timedelta enhancement
- Next message: [Python-Dev] datetime and timedelta enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
1- convert a datetime object to an epoch value (numbers of seconds since the 1st january 1970), eg. with a new totimestamp() method 2- convert a timedelta to a specific unit (eg. seconds, days, weeks, etc.)
Another solution is proposed by Christian Heimes: "implement int and float on timedelta objects: int(timedelta) -> seconds, float(timedelta) -> seconds.micros".
This solution only answer to the need "conversion to seconds" (which is the most common case). To get week, you would have to write: int(dt) / (3600247) which feels me less natural (pythonic?) than: dt // timedelta(days=7)
-- Victor Stinner aka haypo http://www.haypocalc.com/blog/
- Previous message: [Python-Dev] datetime and timedelta enhancement
- Next message: [Python-Dev] datetime and timedelta enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]