Permalink
Browse files

fix bug in date calculation and corrected _age_hours --> _age_minutes

  • Loading branch information...
1 parent 8026624 commit f4fab25f8688c7bea7da48e4fbbf8f977b2e6147 @briandorsey briandorsey committed Dec 28, 2012
Showing with 6 additions and 5 deletions.
  1. +5 −4 main.py
  2. +1 −1 templates/index.html
View
9 main.py
@@ -68,12 +68,12 @@ def annotate_instances(instances):
break
instance['_excluded'] = excluded
- # set _age_hours and _timeout_expired
+ # set _age_minutes and _timeout_expired
# _timeout_expired is never True for _excluded inst
creation = parse_iso8601tz(instance['creationTimestamp'])
now = datetime.datetime.now()
delta = now - creation
- instance['_age_hours'] = delta.seconds / 60
+ instance['_age_minutes'] = delta.seconds / 60
if delta.seconds > CONFIG['TIMEOUT'] * 60 and not instance['_excluded']:
instance['_timeout_expired'] = True
else:
@@ -157,6 +157,7 @@ def parse_iso8601tz(date_string):
delta = datetime.timedelta(minutes=int(date_string[-2:]),
hours=int(date_string[-5:-3]))
if date_string[-6] == '-':
- delta = delta * -1
- dt = dt - delta
+ dt = dt - delta
+ else:
+ dt = dt + delta
return dt
View
2 templates/index.html
@@ -41,7 +41,7 @@
{% for i in instances %}
<tr {{'class="expired"' if i._timeout_expired}}>
<td>{{i.name}}</td>
- <td>{{i._age_hours}}</td>
+ <td>{{i._age_minutes}}</td>
<td>{{i.creationTimestamp}}</td>
<td>{{i.machineType.split('/')[-1]}}</td>
<td>{{i._excluded}}</td>

0 comments on commit f4fab25

Please sign in to comment.