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