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)
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)
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)))
def test_diff_for_humans_other_and_months(self): self.assertEqual('2 months before', Date.today().diff_for_humans(Date.today().add(months=2)))
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)))
def test_diff_for_humans_other_and_weeks(self): self.assertEqual('2 weeks before', Date.today().diff_for_humans(Date.today().add(weeks=2)))
def test_diff_for_humans_other_and_days(self): self.assertEqual('2 days before', Date.today().diff_for_humans(Date.today().add(days=2)))
def test_diff_for_humans_now_and_future_years(self): self.assertEqual('2 years from now', Date.today().add(years=2).diff_for_humans())
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())
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)
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)))
def test_start_of_century_from_last_day(): d = Date(2100, 12, 31) new = d.start_of("century") assert_date(new, 2001, 1, 1)
def test_diff_for_humans_other_and_years(self): self.assertEqual('2 years before', Date.today().diff_for_humans(Date.today().add(years=2)))
def test_average_is_fluid(): d = Date.today().average() assert isinstance(d, Date)
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)))
def test_start_of_year_from_last_day(): d = Date(2000, 12, 31) new = d.start_of("year") assert_date(new, 2000, 1, 1)
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)))
def test_end_of_month(): d = Date(2000, 1, 1).end_of("month") new = d.end_of("month") assert_date(new, 2000, 1, 31)
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)))
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)
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)))
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)
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)))
def test_end_of_decade_is_fluid(): d = Date.today() assert isinstance(d.end_of("decade"), Date)
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)))
def test_end_of_decade_from_last_day(): d = Date(2009, 12, 31) new = d.end_of("decade") assert_date(new, 2009, 12, 31)
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)))
def test_start_of_century_from_first_day(): d = Date(2001, 1, 1) new = d.start_of("century") assert_date(new, 2001, 1, 1)
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))
def test_end_of_century_is_fluid(): d = Date.today() assert isinstance(d.end_of("century"), Date)
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))
def test_end_of_century_from_last_day(): d = Date(2100, 12, 31) new = d.end_of("century") assert_date(new, 2100, 12, 31)
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))
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)
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())
def test_start_of_year_from_now(): d = Date.today() new = d.start_of("year") assert_date(new, d.year, 1, 1)
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())
def test_end_of_month_is_fluid(): d = Date.today() assert isinstance(d.end_of("month"), Date)
def test_diff_in_months_vs_default_now(self): self.assertEqual(12, Date.today().subtract(years=1).diff().in_months())
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)
def test_end_of_year_is_fluid(): d = Date.today() assert isinstance(d.end_of("year"), Date)
def test_end_of_month_from_last_day(): d = Date(2000, 1, 31) new = d.end_of("month") assert_date(new, 2000, 1, 31)
def test_today(): d = Date.today() assert isinstance(d, Date)