Ticket #17937: timezone.diff
File timezone.diff, 1.3 KB (added by , 13 years ago) |
---|
-
django/utils/timezone.py
3 3 This module uses pytz when it's available and fallbacks when it isn't. 4 4 """ 5 5 6 from datetime import date time, timedelta, tzinfo6 from datetime import date, datetime, timedelta, tzinfo 7 7 from threading import local 8 8 import time as _time 9 9 … … 248 248 249 249 The logic is described in Python's docs: 250 250 http://docs.python.org/library/datetime.html#datetime.tzinfo 251 252 Objects of the date type are always naive. 251 253 """ 252 return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None 254 if isinstance(value, date): 255 return False 256 else: 257 return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None 253 258 254 259 def is_naive(value): 255 260 """ … … 257 262 258 263 The logic is described in Python's docs: 259 264 http://docs.python.org/library/datetime.html#datetime.tzinfo 265 266 Objects of the date type are always naive. 260 267 """ 261 return value.tzinfo is None or value.tzinfo.utcoffset(value) is None 268 if isinstance(value, date): 269 return True 270 else: 271 return value.tzinfo is None or value.tzinfo.utcoffset(value) is None 262 272 263 273 def make_aware(value, timezone): 264 274 """