本文整理匯總了Python中pyasm.common.SPTDate.convert_to_timezone方法的典型用法代碼示例。如果您正苦於以下問題:Python SPTDate.convert_to_timezone方法的具體用法?Python SPTDate.convert_to_timezone怎麽用?Python SPTDate.convert_to_timezone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyasm.common.SPTDate
的用法示例。
在下文中一共展示了SPTDate.convert_to_timezone方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_timezone_value
# 需要導入模塊: from pyasm.common import SPTDate [as 別名]
# 或者: from pyasm.common.SPTDate import convert_to_timezone [as 別名]
def get_timezone_value(my, value):
'''given a datetime value, try to convert to timezone specified in the widget.
If not specified, use the My Preferences time zone'''
timezone = my.get_option('timezone')
if not timezone:
timezone = PrefSetting.get_value_by_key('timezone')
if timezone in ["local", '']:
value = SPTDate.convert_to_local(value)
else:
value = SPTDate.convert_to_timezone(value, timezone)
return value
示例2: get_format_value
# 需要導入模塊: from pyasm.common import SPTDate [as 別名]
# 或者: from pyasm.common.SPTDate import convert_to_timezone [as 別名]
#.........這裏部分代碼省略.........
elif format == '13:37':
if not value:
value = ''
else:
value = parser.parse(value)
value = value.strftime("%H:%M")
elif format == '13:37:46':
if not value:
value = ''
else:
value = parser.parse(value)
value = value.strftime("%H:%M:%S")
elif format == '01:37 PM':
if not value:
value = ''
else:
value = parser.parse(value)
value = value.strftime("%I:%M %p")
elif format == '01:37:46 PM':
if not value:
value = ''
else:
value = parser.parse(value)
from pyasm.common import SPTDate
timezone = my.get_option('timezone')
if not timezone:
pass
elif timezone == "local":
value = SPTDate.convert_to_local(value)
else:
value = SPTDate.convert_to_timezone(value, "EDT")
value = value.strftime("%I:%M:%S %p")
elif format == '31/12/99 13:37':
if not value:
value = ''
else:
value = parser.parse(value)
value = value.strftime("%d/%m/%y %H:%M")
elif format == '31/12/99 13:37:46':
if not value:
value = ''
else:
value = parser.parse(value)
value = value.strftime("%d/%m/%y %H:%M:%S")
elif format == 'DATETIME':
if not value:
value = ''
else:
value = parser.parse(value)
setting = ProdSetting.get_value_by_key('DATETIME')
if not setting:
setting = "%Y-%m-%d %H:%M"
value = value.strftime(setting)
elif format == 'DATE':
if not value:
value = ''
else:
value = parser.parse(value)