本文整理汇总了Python中dimagi.utils.dates.DateSpan.from_month方法的典型用法代码示例。如果您正苦于以下问题:Python DateSpan.from_month方法的具体用法?Python DateSpan.from_month怎么用?Python DateSpan.from_month使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dimagi.utils.dates.DateSpan
的用法示例。
在下文中一共展示了DateSpan.from_month方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: datespan
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def datespan(self):
if self._datespan is None:
datespan = DateSpan.from_month(self.month, self.year)
self.request.datespan = datespan
self.context.update(dict(datespan=datespan))
self._datespan = datespan
return self._datespan
示例2: datespan
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def datespan(self):
now = datetime.datetime.utcnow()
year, month = add_months(now.year, now.month, -1)
last_month = DateSpan.from_month(month, year)
self.request.datespan = last_month
self.context.update(dict(datespan=last_month))
return last_month
示例3: handle
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def handle(self, month_years, **options):
datespan_list = []
for arg in month_years:
month_year = dateutil.parser.parse(arg)
datespan_list.append(DateSpan.from_month(month_year.month, month_year.year))
generator = MALTTableGenerator(datespan_list)
print("Building Malt table... for time range {}".format(datespan_list))
generator.build_table()
print("Finished!")
示例4: test_app_submission_breakdown
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def test_app_submission_breakdown(self, combination_count_list):
"""
The breakdown of this report is (app, device, userid, username): count
"""
domain = 'test-data-analytics'
received = datetime(2016, 3, 24)
month = DateSpan.from_month(3, 2016)
for app, device, userid, username, count in combination_count_list:
for i in range(count):
save_to_es_analytics_db(domain, received, app, device, userid, username)
self.es.indices.refresh(XFORM_INDEX_INFO.index)
data_back = get_app_submission_breakdown_es(domain, month)
normalized_data_back = set(data_back)
self.assertEqual(set(combination_count_list), normalized_data_back)
示例5: _last_month_datespan
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def _last_month_datespan():
today = datetime.date.today()
first_of_this_month = datetime.date(day=1, month=today.month, year=today.year)
last_month = first_of_this_month - datetime.timedelta(days=1)
return DateSpan.from_month(last_month.month, last_month.year)
示例6: update_current_MALT
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def update_current_MALT():
today = datetime.date.today()
this_month = DateSpan.from_month(today.month, today.year)
MALTTableGenerator([this_month]).build_table()
示例7: datespan
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def datespan(self):
return DateSpan.from_month(month, year)
示例8: datespan
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def datespan(self):
return DateSpan.from_month(self.month, self.year, inclusive=True)
示例9: datespan
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import from_month [as 别名]
def datespan(self):
return DateSpan.from_month(self.month, self.year)