Skip to content

Commit

Permalink
fix(convert): change convert to scientific
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanArhancet committed Dec 25, 2021
1 parent c49de2e commit 4b47805
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pydantic/datetime_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
)

# Support scientific notation
scientific_notation = re.compile(r'^(?P<sign>[-+]?)' r'(?P<scientific_notation>\d+(.\d+)?[eE][+\-]?\d+)?' r'$')
scientific_notation = re.compile(r'^(?P<sign>[-+]?)(?P<scientific_notation>\d+(.\d+)?[eE][+\-]?\d+)?$')

EPOCH = datetime(1970, 1, 1)
# if greater than this, the number is in ms, if less than or equal it's in seconds
Expand Down Expand Up @@ -249,7 +249,7 @@ def parse_duration(value: StrBytesIntFloat) -> timedelta:
kw['microseconds'] = '-' + kw['microseconds']

if kw.get('scientific_notation'):
kw['seconds'] = ("%.17s" % kw.pop('scientific_notation')).rstrip('0').rstrip('.')
kw['seconds'] = "{:.8s}".format(kw.pop('scientific_notation'))

kw_ = {k: float(v) for k, v in kw.items() if v is not None}

Expand Down

0 comments on commit 4b47805

Please sign in to comment.