2
0
Эх сурвалжийг харах

Do proper parsing of timezones and store them as offset seconds.

Jelmer Vernooij 16 жил өмнө
parent
commit
4856af1bde
1 өөрчлөгдсөн 8 нэмэгдсэн , 3 устгасан
  1. 8 3
      dulwich/objects.py

+ 8 - 3
dulwich/objects.py

@@ -454,11 +454,16 @@ class Tree(ShaFile):
 
 
 def parse_timezone(text):
-    return int(text)
+    offset = int(text)
+    hours = int(offset / 100)
+    minutes = (offset % 100)
+    return (hours * 3600) + (minutes * 60)
 
 
-def format_timezone(text):
-    return "%+04d" % text
+def format_timezone(offset):
+    if offset % 60 != 0:
+        raise ValueError("Unable to handle non-minute offset.")
+    return ' %+03d%02d' % (offset / 3600, (offset / 60) % 60)
 
 
 class Commit(ShaFile):