Author: croberts
Date: 2011-05-24 20:28:55 +0000 (Tue, 24 May 2011)
New Revision: 4783
Modified:
trunk/cumin/python/cumin/objectselector.py
trunk/rosemary/python/rosemary/util.py
Log:
Fix for human-readable uptime hours/days calculation.
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2011-05-24 18:01:45 UTC (rev 4782)
+++ trunk/cumin/python/cumin/objectselector.py 2011-05-24 20:28:55 UTC (rev 4783)
@@ -560,10 +560,12 @@
class MonitorSelfAgeColumn(ObjectTableColumn):
def render_cell_content(self, session, record):
- mins, secs = divmod(self.field.get_content(session, record), 60)
- hours, mins = divmod(mins, 60)
- days = hours / 24
- return '%02d:%02d:%02d:%02d' % (days, hours, mins, secs)
+ value = self.field.get_content(session, record)
+ days = value / 86400
+ hours = (value / 3600) - (days * 24)
+ minutes = (value / 60) - (days * 1440) - (hours * 60)
+ seconds = value % 60
+ return '%02d:%02d:%02d:%02d' % (days, hours, minutes, seconds)
class ExportButton(Widget):
def __init__(self, app, name, args, exporter, file_name):
Modified: trunk/rosemary/python/rosemary/util.py
===================================================================
--- trunk/rosemary/python/rosemary/util.py 2011-05-24 18:01:45 UTC (rev 4782)
+++ trunk/rosemary/python/rosemary/util.py 2011-05-24 20:28:55 UTC (rev 4783)
@@ -17,7 +17,8 @@
return fmt_bytes(value * 1024)
def fmt_timestamp_ddhhmmss(value):
- mins, secs = divmod(value, 60)
- hours, mins = divmod(mins, 60)
- days = hours / 24
- return '%02d:%02d:%02d:%02d' % (days, hours, mins, secs)
\ No newline at end of file
+ days = value / 86400
+ hours = (value / 3600) - (days * 24)
+ minutes = (value / 60) - (days * 1440) - (hours * 60)
+ seconds = value % 60
+ return '%02d:%02d:%02d:%02d' % (days, hours, minutes, seconds)
\ No newline at end of file
Show replies by date