diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2011-04-26 09:42:54 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2011-04-26 09:42:54 +0200 |
commit | 73f15f317e1ac5c193ee34f0cbce59adbb9af5b3 (patch) | |
tree | aa4c43e5d532637ba4bac26203117af5aad3aa2e /date.py | |
parent | ddb1cca3c986cac3af2866bb9800b39f99bb262d (diff) | |
download | logilab-common-73f15f317e1ac5c193ee34f0cbce59adbb9af5b3.tar.gz |
date: shortcut to avoid recreating a datetime when not necessary
Diffstat (limited to 'date.py')
-rw-r--r-- | date.py | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -304,9 +304,13 @@ def ustrftime(somedate, fmt='%Y-%m-%d'): return unicode(fmt) % fields def utcdatetime(dt): + if dt.tzinfo is None: + return dt return datetime(*dt.utctimetuple()[:7]) def utctime(dt): + if dt.tzinfo is None: + return dt return (dt + dt.utcoffset() + dt.dst()).replace(tzinfo=None) def datetime_to_seconds(date): |