本文整理汇总了Python中pyasm.common.SPTDate.get_time_ago方法的典型用法代码示例。如果您正苦于以下问题:Python SPTDate.get_time_ago方法的具体用法?Python SPTDate.get_time_ago怎么用?Python SPTDate.get_time_ago使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.SPTDate
的用法示例。
在下文中一共展示了SPTDate.get_time_ago方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_format_value
# 需要导入模块: from pyasm.common import SPTDate [as 别名]
# 或者: from pyasm.common.SPTDate import get_time_ago [as 别名]
#.........这里部分代码省略.........
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)
setting = ProdSetting.get_value_by_key('DATE')
if not setting:
setting = "%Y-%m-%d"
value = value.strftime(setting)
elif format == 'TIME_AGO':
if not value:
value = ''
else:
value = parser.parse(value)
from pyasm.common import SPTDate
value = SPTDate.convert(value)
value = SPTDate.get_time_ago(value)
# ------------------------------------------------
# Scientific
elif format == '-1.23E+03':
if not value:
value = ''
else:
try:
value = "%.2e" % self.convert_to_float(value)
except:
value = "0.00"
elif format == '-1.234E+03':
if not value:
value = ''
else:
try:
value = "%.2e" % self.convert_to_float(value)
except:
value = "0.00"
# ------------------------------------------------
# Boolean
# false = 0, true = 1
elif format in ['True|False']:
if value:
value = 'True'
else:
value = 'False'
示例2: get_format_value
# 需要导入模块: from pyasm.common import SPTDate [as 别名]
# 或者: from pyasm.common.SPTDate import get_time_ago [as 别名]
#.........这里部分代码省略.........
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)
from pyasm.biz import ProdSetting
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)
from pyasm.biz import ProdSetting
setting = ProdSetting.get_value_by_key('DATE')
if not setting:
setting = "%Y-%m-%d"
value = value.strftime(setting)
elif format == 'TIME_AGO':
if not value:
value = ''
else:
value = parser.parse(value)
from pyasm.common import SPTDate
value = SPTDate.get_time_ago(value)
# ------------------------------------------------
# Scientific
elif format == '-1.23E+03':
if not value:
value = ''
else:
try:
value = "%.2e" % self.convert_to_float(value)
except:
value = "0.00"
elif format == '-1.234E+03':
if not value:
value = ''
else:
try:
value = "%.2e" % self.convert_to_float(value)
except:
value = "0.00"
# ------------------------------------------------
# Boolean
# false = 0, true = 1
elif format in ['True|False']:
if value:
value = 'True'
else:
value = 'False'
elif format in ['true|false']: