本文整理汇总了Python中dimagi.utils.dates.DateSpan.is_default方法的典型用法代码示例。如果您正苦于以下问题:Python DateSpan.is_default方法的具体用法?Python DateSpan.is_default怎么用?Python DateSpan.is_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dimagi.utils.dates.DateSpan
的用法示例。
在下文中一共展示了DateSpan.is_default方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: datespan_from_beginning
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import is_default [as 别名]
def datespan_from_beginning(domain_object, timezone):
if use_new_exports(domain_object.name):
startdate = domain_object.date_created
else:
startdate = get_first_form_submission_received(domain_object.name)
now = datetime.utcnow()
datespan = DateSpan(startdate, now, timezone=timezone)
datespan.is_default = True
return datespan
示例2: datespan_from_beginning
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import is_default [as 别名]
def datespan_from_beginning(domain_object, timezone):
from corehq import toggles
if toggles.NEW_EXPORTS.enabled(domain_object.name):
startdate = domain_object.date_created
else:
startdate = get_first_form_submission_received(domain_object.name)
now = datetime.utcnow()
datespan = DateSpan(startdate, now, timezone=timezone)
datespan.is_default = True
return datespan
示例3: datespan_from_beginning
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import is_default [as 别名]
def datespan_from_beginning(domain, default_days, timezone):
now = datetime.utcnow()
def extract_date(x):
try:
def clip_timezone(datestring):
return datestring[:len('yyyy-mm-ddThh:mm:ss')]
return string_to_datetime(clip_timezone(x['key'][2]))
except Exception:
logging.error("Tried to get a date from this, but it didn't work: %r" % x)
return None
key = make_form_couch_key(domain)
startdate = get_db().view('reports_forms/all_forms',
startkey=key,
endkey=key+[{}],
limit=1,
descending=False,
reduce=False,
wrapper=extract_date,
).one() #or now - timedelta(days=default_days - 1)
datespan = DateSpan(startdate, now, timezone=timezone)
datespan.is_default = True
return datespan
示例4: datespan_from_beginning
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import is_default [as 别名]
def datespan_from_beginning(domain, timezone):
now = datetime.utcnow()
startdate = get_first_form_submission_received(domain)
datespan = DateSpan(startdate, now, timezone=timezone)
datespan.is_default = True
return datespan
示例5: datespan_from_beginning
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import is_default [as 别名]
def datespan_from_beginning(domain_object, timezone):
startdate = domain_object.date_created
now = datetime.utcnow()
datespan = DateSpan(startdate, now, timezone=timezone)
datespan.is_default = True
return datespan
示例6: default_datespan
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import is_default [as 别名]
def default_datespan(self):
last_period_st, last_period_end = calculate_last_period(datetime.now())
datespan = DateSpan(startdate=last_period_st, enddate=last_period_end)
datespan.is_default = True
return datespan
示例7: default_datespan
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import is_default [as 别名]
def default_datespan(self):
start, end = HQMonthlyBill.get_default_start_end()
datespan = DateSpan(start, end, format="%Y-%m-%d", timezone=self.timezone)
datespan.is_default = True
return datespan