summaryrefslogtreecommitdiff
path: root/iso8601/iso8601.py
diff options
context:
space:
mode:
Diffstat (limited to 'iso8601/iso8601.py')
-rw-r--r--iso8601/iso8601.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/iso8601/iso8601.py b/iso8601/iso8601.py
index a121e2e..b979f02 100644
--- a/iso8601/iso8601.py
+++ b/iso8601/iso8601.py
@@ -13,6 +13,7 @@ from datetime import (
timedelta,
tzinfo
)
+from decimal import Decimal
import logging
import sys
import re
@@ -28,7 +29,8 @@ else:
# Adapted from http://delete.me.uk/2005/03/iso8601.html
-ISO8601_REGEX = re.compile(r"""
+ISO8601_REGEX = re.compile(
+ r"""
(?P<year>[0-9]{4})
(-{0,1}(?P<month>[0-9]{1,2})){1}
(-{0,1}(?P<day>[0-9]{1,2})){1}
@@ -159,7 +161,7 @@ def parse_date(datestring, default_timezone=UTC):
tz = parse_timezone(groups, default_timezone=default_timezone)
- groups["second_fraction"] = int(float("0.%s" % to_int(groups, "second_fraction", default_to_zero=True)) * 1e6)
+ groups["second_fraction"] = int(Decimal("0.%s" % to_int(groups, "second_fraction", default_to_zero=True)) * Decimal("1000000.0"))
try:
return datetime(