本文整理汇总了Python中django.utils.timezone._get_timezone_name方法的典型用法代码示例。如果您正苦于以下问题:Python timezone._get_timezone_name方法的具体用法?Python timezone._get_timezone_name怎么用?Python timezone._get_timezone_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.utils.timezone
的用法示例。
在下文中一共展示了timezone._get_timezone_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_instance_bound
# 需要导入模块: from django.utils import timezone [as 别名]
# 或者: from django.utils.timezone import _get_timezone_name [as 别名]
def on_instance_bound(self):
super().on_instance_bound()
if not self.form:
# wait for the form to be set, it will eventually be
return
if not self.instance.overrides:
return
widget = self.form[self.field_name].field.widget
widget.overrides_repeat = self.instance.overrides_repeat
tz = timezone._get_timezone_name(self.instance.tz)
if tz != timezone.get_current_timezone_name():
self.exceptionTZ = tz
else:
self.exceptionTZ = None
# ------------------------------------------------------------------------------
示例2: __init__
# 需要导入模块: from django.utils import timezone [as 别名]
# 或者: from django.utils.timezone import _get_timezone_name [as 别名]
def __init__(self, lookup, lookup_type, tzinfo):
super(DateTime, self).__init__(output_field=fields.DateTimeField())
self.lookup = lookup
self.col = None
self.lookup_type = lookup_type
if tzinfo is None:
self.tzname = None
else:
self.tzname = timezone._get_timezone_name(tzinfo)
self.tzinfo = tzinfo
示例3: get_tzname
# 需要导入模块: from django.utils import timezone [as 别名]
# 或者: from django.utils.timezone import _get_timezone_name [as 别名]
def get_tzname(self):
# Timezone conversions must happen to the input datetime *before*
# applying a function. 2015-12-31 23:00:00 -02:00 is stored in the
# database as 2016-01-01 01:00:00 +00:00. Any results should be
# based on the input datetime not the stored datetime.
tzname = None
if settings.USE_TZ:
if self.tzinfo is None:
tzname = timezone.get_current_timezone_name()
else:
tzname = timezone._get_timezone_name(self.tzinfo)
return tzname