Permalink
Browse files

improve templatetag conv_min and time_in_min

  • Loading branch information...
areski committed Jun 26, 2012
1 parent 5adf158 commit 1f0bb6eefe1ca1f0da763c9ea7cf930729d9d049
Showing with 12 additions and 2 deletions.
  1. +12 −2 common/templatetags/common_tags.py
@@ -26,7 +26,12 @@
@register.filter()
def time_in_min(value, arg):
"""Convert value in min or second format"""
- if int(value)!=0:
+ try:
+ value = int(value)
+ except:
+ value = 0
+
+ if value != 0:
if arg == 'min':
min = int(value / 60)
sec = int(value % 60)
@@ -44,7 +49,12 @@ def time_in_min(value, arg):
@register.filter()
def conv_min(value):
"""Convert value in min:sec format"""
- if int(value)!=0:
+ try:
+ value = int(value)
+ except:
+ value = 0
+
+ if value != 0:
min = int(value / 60)
sec = int(value % 60)
return "%02d" % min + ":" + "%02d" % sec

0 comments on commit 1f0bb6e

Please sign in to comment.