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