本文整理匯總了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