Handle None values !
authorThierry Florac <tflorac@ulthar.net>
Tue, 02 Mar 2010 23:34:55 +0100
changeset 33 11b11c5a4f9e
parent 32 266139614a46
child 34 9b882e41b6d2
Handle None values !
ztfy/utils/timezone.py
--- a/ztfy/utils/timezone.py	Tue Mar 02 23:34:27 2010 +0100
+++ b/ztfy/utils/timezone.py	Tue Mar 02 23:34:55 2010 +0100
@@ -16,8 +16,8 @@
 $Id: $
 """
 
-__version__   = "$Revision: $"
-__release__   = "$Id: $"
+__version__ = "$Revision: $"
+__release__ = "$Id: $"
 __docformat__ = "restructuredtext"
 
 # import standard packages
@@ -43,16 +43,20 @@
 @implementer(ITZInfo)
 @adapter(IBrowserRequest)
 def tzinfo(request=None):
-     return tz
+    return tz
 
 
 def tztime(value):
+    if not value:
+        return None
     if not value.tzinfo:
         value = GMT.localize(value)
     return value.astimezone(tz)
 
 
 def gmtime(value):
+    if not value:
+        return None
     if not value.tzinfo:
         value = GMT.localize(value)
     return value.astimezone(GMT)