parsedatetime
parsedatetime copied to clipboard
'last year' vs 'last 5 years'
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!
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.
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 .