Пример #1
0
def get_dates(dt):
    if is_period_id(dt):
        start = start_of_period(dt)
        end =end_of_period(dt)
    elif type(dt) in [str, unicode] and dt[-4:]=='_YTD':
        end = parse(dt[:-4])
        start = datetime.date(end.year, 1, 1)
    elif type(dt) in [str, unicode] and dt[0] == 'D':
        d = parse(dt[1:]).date()
        start = prev_busday(d)+datetime.timedelta(days=1)
        end = d
    elif dt=='today':
        start = settings.DATE_EARLY
        end = datetime.datetime.now().date()
    else:
        start = settings.DATE_EARLY
        if type(dt)==str:
            end = parse(dt).date()
        else:
            end = dt
    return start, end
Пример #2
0
def get_dates(dt):
    if is_period_id(dt):
        start = start_of_period(dt)
        end =end_of_period(dt)
    elif type(dt) in [str, unicode] and dt[-4:]=='_YTD':
        end = parse(dt[:-4])
        start = datetime.date(end.year, 1, 1)
    elif type(dt) in [str, unicode] and dt[0] == 'D':
        d = parse(dt[1:]).date()
        start = prev_busday(d)+datetime.timedelta(days=1)
        end = d
    elif dt=='today':
        start = settings.DATE_EARLY
        end = datetime.datetime.now().date()
    else:
        start = settings.DATE_EARLY
        if type(dt)==str:
            end = parse(dt).date()
        else:
            end = dt
    return start, end
Пример #3
0
def periods(period_tags):
    periods = {}
    for tag in period_tags:
        period_tag = period_tags[tag]
        periods[tag] = {'start': start_of_period(period_tag), 'end': end_of_period(period_tag)}
    return periods
Пример #4
0
def periods(period_tags):
    periods = {}
    for tag in period_tags:
        period_tag = period_tags[tag]
        periods[tag] = {'start': start_of_period(period_tag), 'end': end_of_period(period_tag)}
    return periods