Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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)
Esempio n. 4
0
def localize_settings_changed(**kwargs):
    if kwargs['setting'] in FORMAT_SETTINGS or kwargs['setting'] == 'USE_THOUSAND_SEPARATOR':
        reset_format_cache()
Esempio n. 5
0
def localize_settings_changed(**kwargs):
    if kwargs['setting'] in FORMAT_SETTINGS or kwargs['setting'] == 'USE_THOUSAND_SEPARATOR':
        reset_format_cache()
Esempio n. 6
0
def localize_settings_changed(**kwargs):
    if (kwargs["setting"] in FORMAT_SETTINGS
            or kwargs["setting"] == "USE_THOUSAND_SEPARATOR"):
        reset_format_cache()
Esempio n. 7
0
 def setUpClass(cls):
     super(ObjectDetailMixin, cls).setUpClass()
     reset_format_cache()  # Reset cache with formats for date and time.
Esempio n. 8
0
def localize_settings_changed(*, setting, **kwargs):
    if setting in FORMAT_SETTINGS or setting == "USE_THOUSAND_SEPARATOR":
        reset_format_cache()