From 8a63842725558d8877a933bbd1f5312bb8e6f195 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Thu, 17 May 2012 09:38:44 +0200 Subject: [PATCH] print age of backups --- shbackup | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/shbackup b/shbackup index a45305e..0cfc4c7 100755 --- a/shbackup +++ b/shbackup @@ -57,8 +57,14 @@ class Backup: ", mode: " + self.mode + "]" def colAlignedString(self): - return "%16s %8s %4s" % ( \ - self.date.strftime("%Y-%m-%d %H:%M"), self.epoch, self.mode) + age = datetime.datetime.now() - self.date + total_hours = age.total_seconds()/3600 + if total_hours <= 48: + agestr = "(%s h)" % int(total_hours) + else: + agestr = "(%s d)" % age.days + return "%16s %7s %8s %4s" % ( \ + self.date.strftime("%Y-%m-%d %H:%M"), agestr, self.epoch, self.mode) @staticmethod def getDirName(date, epoch, mode): -- 2.30.2