aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-05-25 17:25:21 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-05-25 17:25:21 +0200
commit7f045c0023b4c73517f204e786d616d46698f39a (patch)
treed00e262af8eca21a40152d7339387ffea9359e68
First version that probably works today
-rwxr-xr-xdebdate49
1 files changed, 49 insertions, 0 deletions
diff --git a/debdate b/debdate
new file mode 100755
index 0000000..707376d
--- /dev/null
+++ b/debdate
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+
+import datetime
+import dateutil.relativedelta
+
+# TODO: these will be read from some other file
+RELEASES = [
+ (datetime.date(2015, 4, 25), 'jessie'),
+ (datetime.date(2013, 5, 4), 'wheezy'),
+ (datetime.date(2011, 2, 6), 'squeeze'),
+ (datetime.date(2009, 2, 14), 'lenny'),
+ (datetime.date(2007, 4, 8), 'etch'),
+ (datetime.date(2005, 6, 6), 'sarge'),
+ (datetime.date(2002, 7, 19), 'woody'),
+ (datetime.date(2000, 8, 15), 'potato'),
+ (datetime.date(1999, 3, 9), 'slink'),
+ (datetime.date(1998, 6, 24), 'hamm'),
+ (datetime.date(1997, 7, 2), 'bo'),
+ (datetime.date(1996, 12, 12), 'rex'),
+ (datetime.date(1996, 6, 17), 'buzz'),
+ ]
+MSG = "Today is day {dody} of year {yodr} of the {release}"
+
+
+class DebDate:
+ def get_release(self, day):
+ data = {}
+ for r in RELEASES:
+ epoch = r[0]
+ data['release'] = r[1]
+ if day > epoch:
+ break
+ delta = dateutil.relativedelta.relativedelta(day, epoch)
+ data['dody'] = 0
+ data['yodr'] = delta.years + 1
+ if delta.years == 0:
+ data['dody'] = datetime.timedelta(delta).days
+ else:
+ data['dody'] = day.timetuple().tm_yday
+ return data
+
+ def main(self):
+ today = datetime.date.today()
+ data = self.get_release(today)
+ print(MSG.format(**data))
+
+
+if __name__ == '__main__':
+ DebDate().main()