Skip to content

Commit

Permalink
Merge pull request #50 from jonbwhite/datetime-decimal-context
Browse files Browse the repository at this point in the history
Pass in specific context for datetime quantize operation to prevent error with different decimal defaults
  • Loading branch information
brunato committed Jul 11, 2022
2 parents f539463 + ceff93c commit ea2e255
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions elementpath/datatypes/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import re
import datetime
from calendar import isleap
from decimal import Decimal
from decimal import Decimal, Context
from typing import cast, Any, Callable, Dict, Optional, Tuple, Union

from ..helpers import MONTH_DAYS_LEAP, MONTH_DAYS, DAYS_IN_4Y, \
Expand Down Expand Up @@ -754,7 +754,7 @@ def __init__(self, months: int = 0, seconds: Union[Decimal, int] = 0) -> None:
raise OverflowError("seconds duration overflow")

self.months = months
self.seconds = Decimal(seconds).quantize(Decimal('1.000000'))
self.seconds = Decimal(seconds).quantize(Decimal('1.000000', context=Context(prec=30)))

def __repr__(self) -> str:
return '{}(months={!r}, seconds={})'.format(
Expand Down

0 comments on commit ea2e255

Please sign in to comment.