Skip to content

Conversation

miseran
Copy link

@miseran miseran commented Mar 12, 2022

Currently, a relative time with granularity less than a day will still result in a period of day, even when RETURN_TIME_AS_PERIOD is set:

In [1]: parser = dateparser.date.DateDataParser(settings={'RETURN_TIME_AS_PERIOD': True})

In [2]: parser.get_date_data('in 2 hours')
Out[2]: DateData(date_obj=datetime.datetime(2022, 3, 12, 19, 47, 25, 221085), period='day', locale='en')

This PR changes that behaviour, so that a period of time is is returned in this case.

The PR doesn't change the behaviour when RETURN_TIME_AS_PERIOD is false. This means that in 2 months and 2 hours results in period month, even though the actual granularity is much finer. I find this counter-intuitive, however there are tests for this, so I kept that behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant