Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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