ssoma-mda: Support UTC dates
authorW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 06:10:45 +0000 (22:10 -0800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 06:10:45 +0000 (22:10 -0800)
For example:

  >>> datetime = email.utils.parsedate_to_datetime('Tue, 21 Dec 2010 03:52:23 -0000')
  >>> datetime.utcoffset() is None
  True

so without this case, we'll get:

  AttributeError: 'NoneType' object has no attribute 'seconds'

ssoma-mda

index 99d62b154b829b055a2b1398bfd69f19bb138a84..10b8d3d917a38da4e27d96533840588166974955 100755 (executable)
--- a/ssoma-mda
+++ b/ssoma-mda
@@ -225,7 +225,10 @@ def get_author(message):
     date = message['Date']
     datetime = _email_utils.parsedate_to_datetime(date)
     time = int(datetime.timestamp())
-    offset = datetime.utcoffset().seconds // 60
+    if datetime.utcoffset():
+        offset = datetime.utcoffset().seconds // 60
+    else:
+        offset = 0
     return _pygit2.Signature(
         name=author_name,
         email=author_email,