本文整理汇总了Python中arrow.Arrow.range方法的典型用法代码示例。如果您正苦于以下问题:Python Arrow.range方法的具体用法?Python Arrow.range怎么用?Python Arrow.range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arrow.Arrow
的用法示例。
在下文中一共展示了Arrow.range方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import range [as 别名]
def view(party_id):
"""List orga presence and task time slots for that party."""
party = Party.query.get_or_404(party_id)
presences = Presence.query \
.for_party(party) \
.options(db.joinedload('orga')) \
.all()
tasks = Task.query.for_party(party).all()
time_slots = [party] + tasks
min_starts_at = find_earliest_time_slot_start(time_slots)
max_ends_at = find_latest_time_slot_end(time_slots)
hour_starts_arrow = Arrow.range('hour', min_starts_at, max_ends_at)
hour_starts = [hour_start.datetime.replace(tzinfo=None)
for hour_start in hour_starts_arrow]
hour_ranges = list(map(DateTimeRange._make, pairwise(hour_starts)))
days = [(day, len(list(hour_starts))) for day, hour_starts
in groupby(hour_starts, key=lambda hour: hour.date())]
return {
'party': party,
'days': days,
'hour_ranges': hour_ranges,
'presences': presences,
'tasks': tasks,
}
示例2: _get_hour_starts
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import range [as 别名]
def _get_hour_starts(dt_ranges):
min_starts_at = _find_earliest_start(dt_ranges)
max_ends_at = _find_latest_end(dt_ranges)
hour_starts_arrow = Arrow.range('hour', min_starts_at, max_ends_at)
return _to_datetimes_without_tzinfo(hour_starts_arrow)
示例3: timeloop
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import range [as 别名]
def timeloop(start=datetime.now() + timedelta(days=-1),
end=datetime.now() + timedelta(days=0)):
"生成一个字符串格式为YYYY-MM-DD形式的数组."
if (type(start) is str) or (type(end) is str):
start = start if type(
start) is datetime else datetime.strptime(start, '%Y-%m-%d')
end = datetime.now()
# TODO:检查时间是否为字符串,如果是则转换为时间。
rond = []
for r_time in Arrow.range('day', start, end):
rond.append(r_time.format('YYYY-MM-DD'))
return rond