コード例 #1
0
ファイル: test_dtvals.py プロジェクト: telia-oss/birgitta
def test_daterange():
    today = v.today_datetime()
    inthepast = v.inthepast()
    range_len = dtvals.daterange_len(inthepast, today)
    assert range_len == 59
    range_len = dtvals.daterange_len(None, today)
    assert range_len == 59
    range_len = dtvals.daterange_len(None, None)
    assert range_len == 59
コード例 #2
0
ファイル: test_dtvals.py プロジェクト: telia-oss/birgitta
def test_vals():
    date_val = v.inthepast()
    assert datetime.datetime(2019, 1, 1, 0, 0) == dtvals.timestamp(date_val)
    assert datetime.datetime(2019, 1, 1, 0, 0) == dtvals.timestamp(None)
    assert 20190101 == dtvals.datenum(date_val)
    assert 201901 == dtvals.yearmonthnum(date_val)
    assert '01W00' == dtvals.yearweekstr(date_val)
    assert 9 == dtvals.weeks_ago()
    assert 13 == dtvals.weeks_ago(date=datetime.date(2018, 12, 1))
    assert 5 == dtvals.weeks_ago(date=datetime.date(2018, 11, 1),
                                 today=datetime.date(2018, 12, 1))
    assert not dtvals.is_last_day_in_week(date_val)
    assert 1 == dtvals.day_in_year()
    assert '2019-01-09' == dtvals.second_yearweekstr()
    assert datetime.date(2019, 1, 9) == dtvals.second_yearweek()
    assert 1 == dtvals.isholidayint(datetime.date(2018, 12, 25))
    assert dtvals.yesterdaystr(date_val) == '2018-12-31'
    last_month_date = datetime.datetime(2018,
                                        12,
                                        2,
                                        1,
                                        0,
                                        tzinfo=datetime.timezone.utc)
    assert dtvals.lastmonth(date_val) == last_month_date
コード例 #3
0
    example=1,
    description="Brand code, 1 is Tribune. 44 is the bankrupt Times."
)
catalog.add_field(
    'brand_name',
    example='Tribune',
    description="Brand name, E.g. 'Tribune' or 'Times'."
)
catalog.add_field(
    'current_flag',
    example=1,
    description="Is this the latest/current version of this entry"
)
catalog.add_field(
    'datestamp',
    example=v.inthepast(),
    description="Date stamp"
)
catalog.add_field(
    'shop_code',
    example=tv.shop_code(),
    description="Dealer code"
)
catalog.add_field(
    'end_date',
    example=v.today_datetime(),
    description="Expiration (end) date"
)
catalog.add_field(
    'period_date',
    example=v.inthepast(),
コード例 #4
0
def startdate_yyyymmdd():
    """We have no data before 2019-01-07"""
    return dtvals.datestr(v.inthepast())