aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-05-27 12:34:21 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-05-27 12:34:21 +0200
commit3fb20f12ed07946b57fbcb20b71b95d727c4c868 (patch)
tree0b8b889f5669805a792a0fb1acc5e3c5b2d1fd63
parent2c9a895c70dd6e52fe5a0bfc5805db98d893e2b0 (diff)
Fix calculation of dates for the beginning of the second year
-rwxr-xr-xdebdate15
1 files changed, 12 insertions, 3 deletions
diff --git a/debdate b/debdate
index 5f10c3c..c05d297 100755
--- a/debdate
+++ b/debdate
@@ -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]