本文整理匯總了Python中wikilife_utils.date_utils.DateUtils.get_datetime_utc方法的典型用法代碼示例。如果您正苦於以下問題:Python DateUtils.get_datetime_utc方法的具體用法?Python DateUtils.get_datetime_utc怎麽用?Python DateUtils.get_datetime_utc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wikilife_utils.date_utils.DateUtils
的用法示例。
在下文中一共展示了DateUtils.get_datetime_utc方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_equals_datetime2
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def test_equals_datetime2(self):
d1 = DateUtils.get_datetime_utc()
d2 = DateUtils.get_datetime_utc()
d2 = DateUtils.add_seconds(d2, 1)
assert DateUtils.equals_datetime(d1, d2, 5) == True
assert DateUtils.equals_datetime(d1, d2, 1.1) == True
assert DateUtils.equals_datetime(d1, d2, 0.9) == False
assert DateUtils.equals_datetime(d1, d2) == False
示例2: test_insert_age
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def test_insert_age(self):
prc = self.get_prc_builder().build_processor(AGGR_PRC_ID)
log_nodes = [{"node_id": 1157, "value": "1980-01-15 12:00:00 -0300"}]
log = self.create_final_log(user_id=TEST_USER_ID, log_nodes=log_nodes, start=DateUtils.get_datetime_utc())
prc.insert(log, log["nodes"])
assert True
log_nodes = [{"node_id": 1157, "value": "1985-01-15 12:00:00 -0300"}]
log = self.create_final_log(user_id=TEST_USER_ID, log_nodes=log_nodes, start=DateUtils.get_datetime_utc())
prc.insert(log, log["nodes"])
assert True
示例3: test_insert_sleep
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def test_insert_sleep(self):
prc = self.get_prc_builder().build_processor(AGGR_PRC_ID)
log_nodes = [{"node_id": 241563, "value": 4.5}]
log = self.create_final_log(user_id=TEST_USER_ID, log_nodes=log_nodes, start=DateUtils.get_datetime_utc())
prc.insert(log, log["nodes"])
assert True
log_nodes = [{"node_id": 241563, "value": 2}]
log = self.create_final_log(user_id=TEST_USER_ID, log_nodes=log_nodes, start=DateUtils.get_datetime_utc())
prc.insert(log, log["nodes"])
assert True
示例4: execute
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def execute(self):
start_time = time.time()
prc_status = self._mgrs.cronned_processor_status_mgr.get_cronned_processor_status(self._prc_id)
if prc_status != None:
last_exec_utc = prc_status[LAST_EXEC_UTC_FIELD]
else:
last_exec_utc = DateUtils.get_datetime_utc()
self._mgrs.cronned_processor_status_mgr.insert_cronned_processor_status(self._prc_id, last_exec_utc)
self._logger.info("## %s execute start" %self._prc_id)
self.process()
last_exec_utc = DateUtils.get_datetime_utc()
self._mgrs.cronned_processor_status_mgr.update_cronned_processor_status(self._prc_id, last_exec_utc)
self._logger.info("## %s execute end. Elapsed time: %s seconds" %(self._prc_id, (time.time()-start_time) ) )
示例5: insert
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_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)
示例6: test_process_value
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def test_process_value(self):
factor = SmokingFactor(daos=self._daos, values=[
{"id": "lt1", "name": "less than 1", "min": 0.0, "max": 1.0},
{"id": "1-5", "name": "1 to 10", "min": 1.0, "max": 10.0},
{"id": "gt40", "name": "more than 10", "min": 10.0, "max": None}
])
user_id = "TEST_SmokingFactor"
node_id = 123
exec_date = DateUtils.get_datetime_utc()
raw_value = 8
expected_value = 8
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
raw_value = 9
expected_value = 8+9
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
exec_date = DateUtils.add_days(exec_date, -1)
raw_value = 10
expected_value = (8+9 + 10)/2.0
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
示例7: test_process_value
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def test_process_value(self):
factor = TylenolAcetaminophenPillsFactor(daos=self._daos, values=[
{"id": "lt1", "name": "less than 1", "min": 0.0, "max": 1.0},
{"id": "1-5", "name": "1 to 5", "min": 1.0, "max": 5.0},
{"id": "5-10", "name": "5 to 10", "min": 1.0, "max": 10.0}
])
user_id = "TEST_SexFactor"
node_id = 123
exec_date = DateUtils.get_datetime_utc()
raw_value = 8
expected_value = 1
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
raw_value = 9
expected_value = 1+1
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
exec_date = DateUtils.add_days(exec_date, -1)
raw_value = 10
expected_value = ((1+1)+1)/2.0
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
示例8: test_process_value
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def test_process_value(self):
factor = SleepFactor(daos=self._daos, values=[
{"id": "lt6", "name": "less than 6", "min": 0, "max": 6},
{"id": "6-8", "name": "6 to 8", "min": 6, "max": 8},
{"id": "gt8", "name": "more than 8", "min": 8, "max": None}
])
user_id = "TEST_SleepFactor"
node_id = 123
exec_date = DateUtils.get_datetime_utc()
raw_value = 8*60
expected_value = 8
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
raw_value = 9*60
expected_value = 8+9
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
exec_date = DateUtils.add_days(exec_date, -1)
raw_value = 10*60
expected_value = (8+9 + 10)/2.0
processed_value = factor.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
self.assertEquals(processed_value, expected_value)
示例9: print_final_logs_by_month
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def print_final_logs_by_month(self):
print "Final logs by Month:"
print "==================="
total_logs = self._final_log_dao.get_final_logs_count()
if total_logs > 0:
first_log = self._final_log_dao.get_first_final_log()
date_from = first_log[FL_CREATE_UTC_FIELD]
date_from = datetime.datetime(date_from.year, date_from.month, 1)
date_to = DateUtils.add_months(date_from, 1)
date_now = DateUtils.get_datetime_utc()
print "DB final logs first: %s" %first_log[FL_CREATE_UTC_FIELD]
print "DB final logs total: %s" %total_logs
print "---------------------------------------------"
months = []
while date_from <= date_now:
cursor = self._final_log_dao.get_final_logs_by_create_datetime_utc_range_desc(date_from, date_to)
months.append((date_from, cursor.count()))
date_from = DateUtils.add_months(date_from, 1)
date_to = DateUtils.add_months(date_to, 1)
for month in months:
d, count = month
print "%s-%02d: %s" %(d.year, d.month, count)
else:
print "No final logs found"
示例10: insert_session
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def insert_session(self, developer_id, token):
"""
developer_id: wikilife developer id
token: String
"""
create_utc = DateUtils.get_datetime_utc()
self._sessions_collection.insert({ "developerId": developer_id, "token": token, "create_utc": create_utc})
示例11: _insert_user
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def _insert_user(self, user_id, user_name, pin, auto):
if self._collection.find_one({"userName": user_name}) != None:
raise UserDAOException("User name not available")
create_utc = DateUtils.get_datetime_utc()
self._collection.insert({"createUTC": create_utc, "auto": auto, "userId": user_id, "userName": user_name, "pin": pin, "status": 1})
return user_id
示例12: test_process_value
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def test_process_value(self):
user_id = TEST_USER_ID
f_id = "gender"
node_id = 1159
exec_date = DateUtils.get_datetime_utc()
raw_value = "Female"
factor_id, value = self._aggregation_factors.process_value(raw_value=raw_value, user_id=user_id, node_id=node_id, exec_date=exec_date)
assert factor_id == f_id
assert value == raw_value
示例13: insert_developer
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def insert_developer(self, developer_id, developer_name, password, email):
"""
developer_id: wikilife developer id
developer_name: wikilife developer user name
password: wikilife developer password
email: wikilife developer email
"""
create_utc = DateUtils.get_datetime_utc()
self._developers_collection.insert({ "developerId": developer_id, "developerName": developer_name, "password": password, "email": email,"create_utc": create_utc})
示例14: insert_token
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def insert_token(self, user_id, client_id, token, code):
token_obj = {}
token_obj["createUTC"] = DateUtils.get_datetime_utc()
token_obj["updateUTC"] = None
token_obj["userId"] = user_id
token_obj["code"] = code
token_obj["token"] = token
token_obj["clientId"] = client_id
self._collection.insert(token_obj)
示例15: test_process_value_few_old_data
# 需要導入模塊: from wikilife_utils.date_utils import DateUtils [as 別名]
# 或者: from wikilife_utils.date_utils.DateUtils import get_datetime_utc [as 別名]
def test_process_value_few_old_data(self):
"""
Current daily avg average
"""
print "test_process_value_few_old_data"
daily_avg_day_delta = 90
factor = self._create_factor(daily_avg_day_delta)
current_date = DateUtils.get_datetime_utc()
test_logs, days = self._get_test_logs_few_old_data()
assert self._test_factor(factor, test_logs, days, current_date)