def get_date_range_with_end_date(
        statistical_interval: Optional[str],
        end_date: arrow.Arrow) -> Tuple[arrow.Arrow, arrow.Arrow]:
    # end_date = end_date.shift(days=1)
    if statistical_interval:
        if statistical_interval == "daily":
            # start = end_date.shift(days=-1)
            return end_date.floor('day'), end_date.ceil('day')
        elif statistical_interval == "monthly":
            start = end_date.shift(months=-1)
            return start.floor('day'), end_date.ceil('day')
        elif statistical_interval == "weekly":
            start = end_date.shift(weeks=-1)
            return start.floor('day'), end_date.ceil('day')
    else:
        # start = end_date.shift(days=-1)
        return end_date.floor('day'), end_date.ceil('day')
示例#2
0
def _calendar_range(date: Arrow, period) -> Tuple[Arrow, Arrow]:
    start = date.floor(period).floor("week")
    end = date.ceil(period).ceil("week")
    return start, end