Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for fractional units #876

Merged
4 changes: 2 additions & 2 deletions dateparser/freshness_date_parser.py
Expand Up @@ -11,7 +11,7 @@


_UNITS = r'decade|year|month|week|day|hour|minute|second'
PATTERN = re.compile(r'(\d+)\s*(%s)\b' % _UNITS, re.I | re.S | re.U)
PATTERN = re.compile(r'(\d*\.?\d+)\s*(%s)\b' % _UNITS, re.I | re.S | re.U)
DenverCoder1 marked this conversation as resolved.
Show resolved Hide resolved


class FreshnessDateDataParser:
Expand Down Expand Up @@ -147,7 +147,7 @@ def get_kwargs(self, date_string):

kwargs = {}
for num, unit in m:
kwargs[unit + 's'] = int(num)
kwargs[unit + 's'] = float(num)
if 'decades' in kwargs:
kwargs['years'] = 10 * kwargs['decades'] + kwargs.get('years', 0)
del kwargs['decades']
Expand Down