Browse Source

ISO-8601 parser: Do not convert fraction to float as that leads to precision errors (and has no purpose)

Ask Solem 11 years ago
parent
commit
e4b4bc9259
1 changed files with 2 additions and 3 deletions
  1. 2 3
      celery/utils/iso8601.py

+ 2 - 3
celery/utils/iso8601.py

@@ -69,10 +69,9 @@ def parse_iso8601(datestring):
             hours = -hours
             minutes = -minutes
         tz = FixedOffset(minutes + hours * 60)
-    frac = groups['fraction']
-    groups['fraction'] = int(float('0.%s' % frac) * 1e6) if frac else 0
+    frac = groups['fraction'] or 0
     return datetime(
         int(groups['year']), int(groups['month']), int(groups['day']),
         int(groups['hour']), int(groups['minute']), int(groups['second']),
-        int(groups['fraction']), tz
+        int(frac), tz
     )