本文整理匯總了Python中wikilife_utils.date_utils.DateUtils.to_datetime_utc方法的典型用法代碼示例。如果您正苦於以下問題:Python DateUtils.to_datetime_utc方法的具體用法?Python DateUtils.to_datetime_utc怎麽用?Python DateUtils.to_datetime_utc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wikilife_utils.date_utils.DateUtils
的用法示例。
在下文中一共展示了DateUtils.to_datetime_utc方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: insert
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import to_datetime_utc [as 別名]
def insert(self, final_log, log_nodes):
user_id = final_log["userId"]
date_utc = DateUtils.to_datetime_utc(final_log["start"])
profile = self._daos.profile_dao.get_profile_by_user_id(user_id)
birthdate = DateParser.from_datetime(profile["items"][PROFILE_BIRTHDATE_KEY])
age = (DateUtils.get_datetime_utc() - DateUtils.to_datetime_utc(birthdate)).years
for log_node in log_nodes:
item = self._dao.get_single({"userId": user_id})
if item!=None:
if item["dateUTC"]<=date_utc:
item["age"] = age
item["experience"] = log_node["value"]
item["dateUTC"] = date_utc
self._dao.update(item)
else:
self._logger.info("Attempt to log old value")
else:
item = {}
item["userId"] = user_id
item["age"] = age
item["experience"] = log_node["value"]
item["dateUTC"] = date_utc
self._dao.insert(item)
示例2: update
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import to_datetime_utc [as 別名]
def update(self, final_log, log_nodes, old_final_log, old_log_nodes):
user_id = final_log["userId"]
profile = self._daos.profile_dao.get_profile_by_user_id(user_id)
try:
start_utc = DateUtils.to_datetime_utc(final_log["start"])
except:
start_utc = final_log["start"]
updated = False
if profile == None:
profile = self._daos.profile_dao.get_blank_profile(user_id)
for log_node in final_log["nodes"]:
log_node_id = int(log_node["nodeId"])
key = self._profile_node_map[log_node_id]["name"]
item = profile["items"][key]
if item["updateUTC"]==None or start_utc > item["updateUTC"]:
item["value"] = log_node["value"]
item["updateUTC"] = start_utc
updated = True
if updated:
self._daos.profile_dao.save_profile(profile)
示例3: test_to_datetime_utc
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import to_datetime_utc [as 別名]
def test_to_datetime_utc(self):
local_datetime = DateParser.from_datetime("2012-06-15 10:30:45 -0300")
utc_datetime = DateUtils.to_datetime_utc(local_datetime)
#print local_datetime
#print utc_datetime
assert local_datetime.hour+3 == utc_datetime.hour
assert local_datetime.year == utc_datetime.year
assert local_datetime.month == utc_datetime.month
assert local_datetime.day == utc_datetime.day
assert local_datetime.minute == utc_datetime.minute
assert local_datetime.second == utc_datetime.second
示例4: insert
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import to_datetime_utc [as 別名]
def insert(self, final_log, log_nodes):
user_id = final_log["userId"]
exec_utc = DateUtils.to_datetime_utc(final_log["start"])
#Should always be a single log_node
for log_node in log_nodes:
user_option = self._dao.get_option_by_user_id(user_id)
if user_option!=None:
if user_option["execUTC"]<=exec_utc:
self._dao.update_option(user_id, log_node["value"], exec_utc)
else:
self._logger.info("Attempt to log old value")
else:
self._dao.insert_option(user_id, log_node["value"], exec_utc)