How to use the pendulum.Date function in pendulum

To help you get started, we’ve selected a few pendulum examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sdispater / pendulum / tests / date / test_comparison.py View on Github external
def test_not_equal_to_true():
    d1 = pendulum.Date(2000, 1, 1)
    d2 = pendulum.Date(2000, 1, 2)
    d3 = date(2000, 1, 2)

    assert d1 != d2
    assert d1 != d3
github sdispater / pendulum / tests / date / test_strings.py View on Github external
def test_for_json():
    d = pendulum.Date(1975, 12, 25)
    assert d.for_json() == "1975-12-25"
github sdispater / pendulum / tests / date / test_getters.py View on Github external
def test_week_of_year_last_week():
    assert pendulum.Date(2012, 12, 30).week_of_year == 52
    assert pendulum.Date(2012, 12, 31).week_of_year == 1
github sdispater / pendulum / tests / date / test_comparison.py View on Github external
def test_closest_with_equals():
    instance = pendulum.Date(2015, 5, 28)
    dt1 = pendulum.Date(2015, 5, 28)
    dt2 = pendulum.Date(2015, 5, 30)
    closest = instance.closest(dt1, dt2)
    assert closest == dt1
github sdispater / pendulum / tests / date / test_comparison.py View on Github external
def test_less_than_true():
    d1 = pendulum.Date(2000, 1, 1)
    d2 = pendulum.Date(2000, 1, 2)
    d3 = date(2000, 1, 2)

    assert d1 < d2
    assert d1 < d3
github sdispater / pendulum / tests / date / test_getters.py View on Github external
def test_is_long_year():
    assert pendulum.Date(2015, 1, 1).is_long_year()
    assert not pendulum.Date(2016, 1, 1).is_long_year()
github sdispater / pendulum / tests / date / test_strings.py View on Github external
def test_format_with_locale():
    d = pendulum.Date(1975, 12, 25)
    expected = u"jeudi 25e jour de décembre 1975"
    assert d.format("dddd Do [jour de] MMMM YYYY", locale="fr") == expected
github sdispater / pendulum / tests / date / test_fluent_setters.py View on Github external
def test_fluid_month_setter():
    d = pendulum.Date(2016, 7, 2)
    new = d.set(month=11)

    assert new.month == 11
    assert d.month == 7
github sdispater / pendulum / tests / date / test_construct.py View on Github external
def test_today():
    d = Date.today()

    assert isinstance(d, Date)
github sdispater / pendulum / tests / date / test_behavior.py View on Github external
def test_pickle():
    d1 = pendulum.Date(2016, 8, 27)
    s = pickle.dumps(d1)
    d2 = pickle.loads(s)

    assert isinstance(d2, pendulum.Date)
    assert d2 == d1