summaryrefslogtreecommitdiff
path: root/dateutil/parser/_parser.py
diff options
context:
space:
mode:
authorMateusz Dziedzic <mat.dziedzic@gmail.com>2017-12-07 15:14:37 +0000
committerMateusz Dziedzic <mat.dziedzic@gmail.com>2017-12-07 15:14:37 +0000
commit3b43612c35c7d0918ae96d132a698f7e19c7cdff (patch)
tree12ee3d41d0e7d4a33f11678080b21055fd0b87ea /dateutil/parser/_parser.py
parentfa11a158d27272135db68ae350650d2f16ec0ca0 (diff)
downloaddateutil-git-3b43612c35c7d0918ae96d132a698f7e19c7cdff.tar.gz
Fix issue #427, all tests passing
Diffstat (limited to 'dateutil/parser/_parser.py')
-rw-r--r--dateutil/parser/_parser.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/dateutil/parser/_parser.py b/dateutil/parser/_parser.py
index 2291f39..82be944 100644
--- a/dateutil/parser/_parser.py
+++ b/dateutil/parser/_parser.py
@@ -42,6 +42,8 @@ from io import StringIO
import six
from six import binary_type, integer_types, text_type
+from decimal import Decimal
+
from .. import relativedelta
from .. import tz
@@ -873,7 +875,7 @@ class parser(object):
def _parse_numeric_token(self, tokens, idx, info, ymd, res, fuzzy):
# Token is a number
value_repr = tokens[idx]
- value = float(value_repr)
+ value = Decimal(value_repr)
len_li = len(value_repr)
len_l = len(tokens)
@@ -932,7 +934,7 @@ class parser(object):
elif idx + 2 < len_l and tokens[idx + 1] == ':':
# HH:MM[:SS[.ss]]
res.hour = int(value)
- value = float(tokens[idx + 2]) # TODO: try/except for this?
+ value = Decimal(tokens[idx + 2]) # TODO: try/except for this?
(res.minute, res.second) = self._parse_min_sec(value)
if idx + 4 < len_l and tokens[idx + 3] == ':':
@@ -1032,7 +1034,9 @@ class parser(object):
return hms_idx
def _assign_hms(self, res, value_repr, hms):
- value = float(value_repr)
+ # See GH issue #427, fixing float rounding
+ value = Decimal(value_repr)
+
if hms == 0:
# Hour
res.hour = int(value)