本文整理汇总了Python中pyasm.common.SPTDate.has_timezone方法的典型用法代码示例。如果您正苦于以下问题:Python SPTDate.has_timezone方法的具体用法?Python SPTDate.has_timezone怎么用?Python SPTDate.has_timezone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.SPTDate
的用法示例。
在下文中一共展示了SPTDate.has_timezone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert_value
# 需要导入模块: from pyasm.common import SPTDate [as 别名]
# 或者: from pyasm.common.SPTDate import has_timezone [as 别名]
def convert_value(self, col_type, value):
if col_type == 'timecode':
timecode = TimeCode(timecode=value)
value = timecode.get_frames()
elif col_type in ["time", "timestamp"]:
from pyasm.common import SPTDate
if not value:
value = ""
elif not SPTDate.has_timezone(value):
timezone = PrefSetting.get_value_by_key('timezone')
if timezone:
value = SPTDate.add_timezone(value, timezone)
else:
value = SPTDate.add_local_timezone(value)
elif col_type in ["float", "integer"]:
if isinstance(value, basestring):
value = value.replace(",", "")
if value.startswith("$"):
value = value.lstrip("$")
try:
if not value:
value = None
elif col_type == "float":
value = float(value)
else:
value = int(value)
except:
raise UserException("[%s] must a number." % value)
return value
示例2: convert_value
# 需要导入模块: from pyasm.common import SPTDate [as 别名]
# 或者: from pyasm.common.SPTDate import has_timezone [as 别名]
def convert_value(my, col_type, value):
if col_type == 'timecode':
timecode = TimeCode(timecode=value)
value = timecode.get_frames()
elif col_type in ["time", "timestamp"]:
from pyasm.common import SPTDate
if not SPTDate.has_timezone(value):
value = SPTDate.add_local_timezone(value)
elif col_type in ["float", "integer"]:
if isinstance(value, basestring):
value = value.replace(",", "")
return value
示例3: get_display
# 需要导入模块: from pyasm.common import SPTDate [as 别名]
# 或者: from pyasm.common.SPTDate import has_timezone [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
name = my.get_name()
value = my.get_value()
if sobject:
data_type = SearchType.get_column_type(sobject.get_search_type(), name)
else:
data_type = 'text'
if data_type in ["timestamp","time"] or my.name == "timestamp":
if value == 'now':
value = ''
elif value:
date = parser.parse(value)
# we want to match what's in the db which is server local timezone
if not SPTDate.has_timezone(value):
value = SPTDate.convert_to_local(value)
#value = SPTDate.add_gmt_timezone(date)
value = str(value)
else:
value = ''
return value