From b70005010d6cbbdbecf0dde4cdc2f19928999b1e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 11 Jan 2009 00:36:30 +0530 Subject: [PATCH] do not fail if None is passed to formatDuration --- oxlib/format.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oxlib/format.py b/oxlib/format.py index be7a826..cf7b102 100644 --- a/oxlib/format.py +++ b/oxlib/format.py @@ -174,6 +174,8 @@ def formatDuration(ms, verbosity=0, years=True, hours=True, milliseconds=True): >>> formatDuration(1000 * 30, hours=False, milliseconds=False) '00:30' ''' + if not ms: + return '' if years: y = int(ms / 31536000000) d = int(ms % 31536000000 / 86400000)