Generated: Wed 2013-03-13 10:33 CET
Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/cms/utils/timezone.py
Stats: 0 executed, 18 missed, 4 excluded, 25 ignored
# This file is a partial copy of django.utils.timezone as of Django 1.4.# It must be removed as soon as django-cms drops support for Django 1.3.# All imports of cms.utils.timezone must be replaced by django.utils.timezone.from datetime import datetime, timedelta, tzinfofrom threading import localtry: import pytzexcept ImportError: pytz = Nonefrom django.conf import settingsZERO = timedelta(0)class UTC(tzinfo): """ UTC implementation taken from Python's docs. Used only when pytz isn't available. """ def __repr__(self): return "<UTC>" def utcoffset(self, dt): return ZERO def tzname(self, dt): return "UTC" def dst(self, dt): return ZEROutc = pytz.utc if pytz else UTC()"""UTC time zone as a tzinfo instance."""def now(): """ Returns an aware or naive datetime.datetime, depending on settings.USE_TZ. """ if getattr(settings, 'USE_TZ', False): # timeit shows that datetime.now(tz=utc) is 24% slower return datetime.utcnow().replace(tzinfo=utc) else: return datetime.now()