diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-05-27 12:34:21 +0200 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-05-27 12:34:21 +0200 |
commit | 3fb20f12ed07946b57fbcb20b71b95d727c4c868 (patch) | |
tree | 0b8b889f5669805a792a0fb1acc5e3c5b2d1fd63 | |
parent | 2c9a895c70dd6e52fe5a0bfc5805db98d893e2b0 (diff) |
Fix calculation of dates for the beginning of the second year
-rwxr-xr-x | debdate | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -82,12 +82,12 @@ class DebDate: day=day, ) ) - delta = relativedelta.relativedelta(day, epoch) - data['yodr'] = delta.years + 1 - if delta.years == 0: + if day.year == epoch.year: data['dody'] = (day - epoch).days + data['yodr'] = 1 else: data['dody'] = day.timetuple().tm_yday + data['yodr'] = day.year - epoch.year + 1 return data @@ -122,6 +122,15 @@ class TestDebDate(unittest.TestCase): self.assertEqual(data['yodr'], 2) self.assertEqual(data['release'], r[1]) + def testJanuarySecondYearRelease(self): + for debdate in self.debdates: + r = debdate.releases[-6] + d = datetime.date(r[0].year + 1, 1, 1) + data = debdate.get_release(d) + self.assertEqual(data['dody'], 1) + self.assertEqual(data['yodr'], 2) + self.assertEqual(data['release'], r[1]) + def testPastLatestRelease(self): for debdate in self.debdates: r = debdate.releases[0] |