本文整理汇总了Python中pyasm.common.SPTDate.start_of_today方法的典型用法代码示例。如果您正苦于以下问题:Python SPTDate.start_of_today方法的具体用法?Python SPTDate.start_of_today怎么用?Python SPTDate.start_of_today使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.SPTDate
的用法示例。
在下文中一共展示了SPTDate.start_of_today方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_data
# 需要导入模块: from pyasm.common import SPTDate [as 别名]
# 或者: from pyasm.common.SPTDate import start_of_today [as 别名]
def init_data(my):
sobject = my.get_current_sobject()
value = sobject.get_value(my.due_date_col)
if not value:
my.mode = ""
return
status = sobject.get_value("status")
due_date = parser.parse(value)
# get today's date
from pyasm.common import SPTDate
today = SPTDate.start_of_today()
# get the difference
delta = due_date - today
diff = delta.days
if diff < 0:
if status.lower() in ["approved", "complete", "done"]:
mode = "done"
else:
mode = "critical"
elif diff >= 0 and diff < 1:
mode = "today"
else:
mode = "due"
my.mode = mode
my.diff = diff
示例2: get_display
# 需要导入模块: from pyasm.common import SPTDate [as 别名]
# 或者: from pyasm.common.SPTDate import start_of_today [as 别名]
def get_display(my):
div = DivWdg()
sobject = my.get_current_sobject()
value = sobject.get_value("bid_end_date")
if not value:
return div
status = sobject.get_value("status")
due_date = parser.parse(value)
# get today's date
from pyasm.common import SPTDate
today = SPTDate.start_of_today()
# get the difference
delta = due_date - today
diff = delta.days
if diff < 0:
if status.lower() in ["approved", "complete", "done"]:
mode = "done"
else:
mode = "critical"
elif diff >= 0 and diff < 1:
mode = "today"
else:
mode = "due"
if mode == "critical":
div.add_style("background: #F00")
div.add_style("color: #FFF")
msg = "%s Days" % (-diff)
div.add_attr("title", msg)
if diff == -1:
div.add("Yesterday")
else:
div.add(msg)
elif mode == "today":
div.add_style("background: #00F")
div.add_style("color: #FFF")
div.add_attr("title", "Due today")
div.add("Today")
elif mode == "done":
#div.add_style("background: #0F0")
#div.add_style("color: #000")
#div.add_attr("title", "Done")
#div.add("Done")
pass
else:
div.add_style("background: #FFF")
div.add_style("color: #000")
div.add_attr("title", "Due in %s days" % diff)
if diff == 1:
div.add("Tomorrow")
else:
div.add("%s Days" % diff)
div.add_style("padding: 3px")
div.add_style("text-align: center")
div.add_style("margin: -3px")
return div