def test_end_of_decade_from_now():
    d = Date.today()
    new = d.end_of("decade")
    assert_date(new, d.year - d.year % 10 + 9, 12, 31)
def test_end_of_year_from_last_day():
    d = Date(2000, 12, 31)
    new = d.end_of("year")
    assert_date(new, 2000, 12, 31)
def test_start_of_decade_from_last_day():
    d = Date(2009, 12, 31)
    new = d.start_of("decade")
    assert_date(new, 2000, 1, 1)
def test_start_of_day():
    d = Date.today()
    new = d.start_of("day")
    assert isinstance(new, Date)
    assert_date(new, d.year, d.month, d.day)
Example #5
0
 def test_diff_for_humans_now_and_future_months(self):
     self.assertEqual('2 months from now', Date.today().add(months=2).diff_for_humans())
def test_end_of_century_from_now():
    now = Date.today()
    d = now.end_of("century")
    assert_date(d, now.year - now.year % 100 + 100, 12, 31)
def test_start_of_year_is_fluid():
    d = Date.today()
    new = d.start_of("year")
    assert isinstance(new, Date)
Example #8
0
 def test_diff_for_humans_other_and_nearly_month(self):
     self.assertEqual('3 weeks before', Date.today().diff_for_humans(Date.today().add(weeks=3)))
Example #9
0
 def test_diff_for_humans_other_and_months(self):
     self.assertEqual('2 months before', Date.today().diff_for_humans(Date.today().add(months=2)))
Example #10
0
 def test_diff_for_humans_other_and_nearly_week(self):
     self.assertEqual('6 days before', Date.today().diff_for_humans(Date.today().add(days=6)))
Example #11
0
 def test_diff_for_humans_other_and_weeks(self):
     self.assertEqual('2 weeks before', Date.today().diff_for_humans(Date.today().add(weeks=2)))
Example #12
0
 def test_diff_for_humans_other_and_days(self):
     self.assertEqual('2 days before', Date.today().diff_for_humans(Date.today().add(days=2)))
Example #13
0
 def test_diff_for_humans_now_and_future_years(self):
     self.assertEqual('2 years from now', Date.today().add(years=2).diff_for_humans())
Example #14
0
 def test_diff_for_humans_now_and_nearly_future_year(self):
     self.assertEqual('11 months from now', Date.today().add(months=11).diff_for_humans())
Example #15
0
def test_start_of_century_from_now():
    d = Date.today()
    new = d.start_of("century")
    assert_date(new, d.year - d.year % 100 + 1, 1, 1)
Example #16
0
 def test_diff_for_humans_other_and_nearly_year(self):
     self.assertEqual('11 months before', Date.today().diff_for_humans(Date.today().add(months=11)))
Example #17
0
def test_start_of_century_from_last_day():
    d = Date(2100, 12, 31)
    new = d.start_of("century")
    assert_date(new, 2001, 1, 1)
Example #18
0
 def test_diff_for_humans_other_and_years(self):
     self.assertEqual('2 years before', Date.today().diff_for_humans(Date.today().add(years=2)))
Example #19
0
def test_average_is_fluid():
    d = Date.today().average()
    assert isinstance(d, Date)
Example #20
0
 def test_diff_for_humans_other_and_future_day(self):
     self.assertEqual('1 day after', Date.today().diff_for_humans(Date.today().subtract(days=1)))
Example #21
0
def test_start_of_year_from_last_day():
    d = Date(2000, 12, 31)
    new = d.start_of("year")
    assert_date(new, 2000, 1, 1)
Example #22
0
 def test_diff_for_humans_other_and_nearly_future_week(self):
     self.assertEqual('6 days after', Date.today().diff_for_humans(Date.today().subtract(days=6)))
Example #23
0
def test_end_of_month():
    d = Date(2000, 1, 1).end_of("month")
    new = d.end_of("month")
    assert_date(new, 2000, 1, 31)
Example #24
0
 def test_diff_for_humans_other_and_future_week(self):
     self.assertEqual('1 week after', Date.today().diff_for_humans(Date.today().subtract(weeks=1)))
Example #25
0
def test_end_of_year_from_now():
    d = Date.today().end_of("year")
    new = d.end_of("year")
    assert_date(new, d.year, 12, 31)
Example #26
0
 def test_diff_for_humans_other_and_nearly_future_month(self):
     self.assertEqual('3 weeks after', Date.today().diff_for_humans(Date.today().subtract(weeks=3)))
Example #27
0
def test_start_of_decade_from_now():
    d = Date.today()
    new = d.start_of("decade")
    assert_date(new, d.year - d.year % 10, 1, 1)
Example #28
0
 def test_diff_for_humans_other_and_future_months(self):
     self.assertEqual('2 months after', Date.today().diff_for_humans(Date.today().subtract(months=2)))
Example #29
0
def test_end_of_decade_is_fluid():
    d = Date.today()
    assert isinstance(d.end_of("decade"), Date)
Example #30
0
 def test_diff_for_humans_other_and_nearly_future_year(self):
     self.assertEqual('11 months after', Date.today().diff_for_humans(Date.today().subtract(months=11)))
Example #31
0
def test_end_of_decade_from_last_day():
    d = Date(2009, 12, 31)
    new = d.end_of("decade")
    assert_date(new, 2009, 12, 31)
Example #32
0
 def test_diff_for_humans_other_and_future_years(self):
     self.assertEqual('2 years after', Date.today().diff_for_humans(Date.today().subtract(years=2)))
Example #33
0
def test_start_of_century_from_first_day():
    d = Date(2001, 1, 1)
    new = d.start_of("century")
    assert_date(new, 2001, 1, 1)
Example #34
0
 def test_diff_for_humans_absolute_weeks(self):
     self.assertEqual('2 weeks', Date.today().diff_for_humans(Date.today().subtract(weeks=2), True))
     self.assertEqual('2 weeks', Date.today().diff_for_humans(Date.today().add(weeks=2), True))
Example #35
0
def test_end_of_century_is_fluid():
    d = Date.today()
    assert isinstance(d.end_of("century"), Date)
Example #36
0
 def test_diff_for_humans_absolute_months(self):
     self.assertEqual('2 months', Date.today().diff_for_humans(Date.today().subtract(months=2), True))
     self.assertEqual('2 months', Date.today().diff_for_humans(Date.today().add(months=2), True))
Example #37
0
def test_end_of_century_from_last_day():
    d = Date(2100, 12, 31)
    new = d.end_of("century")
    assert_date(new, 2100, 12, 31)
Example #38
0
 def test_diff_for_humans_absolute_years(self):
     self.assertEqual('1 year', Date.today().diff_for_humans(Date.today().subtract(years=1), True))
     self.assertEqual('1 year', Date.today().diff_for_humans(Date.today().add(years=1), True))
Example #39
0
def test_end_of_week():
    d = Date(2016, 10, 20)
    new = d.end_of("week")
    assert isinstance(new, Date)
    assert_date(new, d.year, d.month, 23)
Example #40
0
 def test_diff_in_months_positive(self):
     dt = Date(2000, 1, 1)
     self.assertEqual(13, dt.diff(dt.add(years=1).add(months=1)).in_months())
Example #41
0
def test_start_of_year_from_now():
    d = Date.today()
    new = d.start_of("year")
    assert_date(new, d.year, 1, 1)
Example #42
0
 def test_diff_in_months_negative_no_sign(self):
     dt = Date(2000, 1, 1)
     self.assertEqual(11, dt.diff(dt.subtract(years=1).add(months=1)).in_months())
Example #43
0
def test_end_of_month_is_fluid():
    d = Date.today()
    assert isinstance(d.end_of("month"), Date)
Example #44
0
 def test_diff_in_months_vs_default_now(self):
     self.assertEqual(12, Date.today().subtract(years=1).diff().in_months())
Example #45
0
def test_end_of_month_from_now():
    d = Date.today().start_of("month")
    new = d.start_of("month")
    assert_date(new, d.year, d.month, 1)
Example #46
0
def test_end_of_year_is_fluid():
    d = Date.today()
    assert isinstance(d.end_of("year"), Date)
Example #47
0
def test_end_of_month_from_last_day():
    d = Date(2000, 1, 31)
    new = d.end_of("month")
    assert_date(new, 2000, 1, 31)
Example #48
0
def test_today():
    d = Date.today()

    assert isinstance(d, Date)