Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mikl/40080 to your computer and use it in GitHub Desktop.
Save mikl/40080 to your computer and use it in GitHub Desktop.
From 8c40a37f625ac0c7ba9811628f49c5ff540954e9 Mon Sep 17 00:00:00 2001
From: Mikkel Hoegh <[email protected]>
Date: Thu, 25 Dec 2008 16:27:41 +0100
Subject: [PATCH] Display time now only displays minutes and hours.
---
apps/tracker/models.py | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/apps/tracker/models.py b/apps/tracker/models.py
index 2ec2634..b944501 100644
--- a/apps/tracker/models.py
+++ b/apps/tracker/models.py
@@ -25,21 +25,17 @@ class Slip(models.Model):
delta = datetime.timedelta(0, seconds)
duration = {
- 'days': delta.days,
- 'hours': floor(delta.seconds / 3600),
- 'minutes': floor((delta.seconds % 3600) / 60),
- 'seconds': delta.seconds % 60
+ 'hours': floor(delta.seconds / 3600) + delta.days * 24,
+ 'minutes': floor((delta.seconds % 3600) / 60)
}
- return '%02i:%02i:%02i:%02i' % (duration['days'],duration['hours'],
- duration['minutes'],duration['seconds'])
+ return '%02i:%02i' % (duration['hours'], duration['minutes'])
def is_active(self):
slice = self.timeslice_set.filter(end = None)
return bool(slice)
-
class Meta:
ordering = ["-created"]
--
1.6.0.6+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment