def getDate(date, reset_cache = True): if (reset_cache == True): formats.reset_format_cache(); tz = timezone.get_current_timezone(); datetime_format = formats.get_format('DATETIME_INPUT_FORMAT_SHORT') naive = datetime.strptime(date, datetime_format) local = tz.localize(naive, is_dst=None) return local
def localToUtc(date, reset_cache = True): if (reset_cache == True): formats.reset_format_cache() tz = timezone.get_current_timezone() datetime_format = formats.get_format('DATETIME_INPUT_FORMAT_SHORT') naive = datetime.strptime(date, datetime_format) local = tz.localize(naive, is_dst=None) utc = local.astimezone(pytz.utc) return utc
def utcToLocal(utc, reset_cache = True): if (reset_cache == True): formats.reset_format_cache() tz = timezone.get_current_timezone() datetime_format = formats.get_format('DATETIME_INPUT_FORMAT_SHORT') if isinstance(utc, datetime): return utc.astimezone(tz) else: utc = datetime.strptime(date, UTC_DATETIME_FORMAT) return utc.astimezone(tz)
def localize_settings_changed(**kwargs): if kwargs['setting'] in FORMAT_SETTINGS or kwargs['setting'] == 'USE_THOUSAND_SEPARATOR': reset_format_cache()
def localize_settings_changed(**kwargs): if kwargs['setting'] in FORMAT_SETTINGS or kwargs['setting'] == 'USE_THOUSAND_SEPARATOR': reset_format_cache()
def localize_settings_changed(**kwargs): if (kwargs["setting"] in FORMAT_SETTINGS or kwargs["setting"] == "USE_THOUSAND_SEPARATOR"): reset_format_cache()
def setUpClass(cls): super(ObjectDetailMixin, cls).setUpClass() reset_format_cache() # Reset cache with formats for date and time.
def localize_settings_changed(*, setting, **kwargs): if setting in FORMAT_SETTINGS or setting == "USE_THOUSAND_SEPARATOR": reset_format_cache()