parsedatetime icon indicating copy to clipboard operation
parsedatetime copied to clipboard

'last year' vs 'last 5 years'

Open carlomazzaferro opened this issue 7 years ago • 2 comments

In brief:

>>> time_struct, parse_status = cal.parse("last fiscal year")
>>> datetime(*time_struct[:6])
datetime.datetime(2018, 4, 5, 13, 46, 25)
>>> time_struct, parse_status = cal.parse("last 5 years")  # same result for 'past 5 years'
>>> datetime(*time_struct[:6])
datetime.datetime(2023, 4, 5, 13, 46, 29)

Is this the default/correct behavior? At least logically it makes little sense to me to get a future date for a some a string that is clearly referencing the past. Maybe someone with a better understanding of the internals of the library can chime in?

Thanks in advance!

carlomazzaferro avatar Apr 05 '18 17:04 carlomazzaferro

What output would you expect for that, it seems like it would have to be 5 dates for each of the last 5 years? Since that construct is not supported it is just identifying the "5 years" portion and ignoring "last". The nlp function is useful for determining how a string is parsed since it includes the substring that matched.

idpaterson avatar Apr 05 '18 19:04 idpaterson

I see. Ideally, I'd get a daterange or timedelta. At first I thought that was supported but I didn't look well enough through the docs. Is it something that is aimed to be supported at all in the future?

Thanks for the pointer, I'll look through the code .

carlomazzaferro avatar Apr 05 '18 19:04 carlomazzaferro