Skip to content

Unable to parse: the 1st [day] of last month #1265

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

Open
sglebs opened this issue Apr 5, 2025 · 2 comments
Open

Unable to parse: the 1st [day] of last month #1265

sglebs opened this issue Apr 5, 2025 · 2 comments

Comments

@sglebs
Copy link

sglebs commented Apr 5, 2025

>>> print(dateparser.parse("today"))
2025-04-05 19:29:42.111011
>>> print(dateparser.parse("the 1st of last month"))
2025-03-05 19:29:46.118149
>>> 

Inserting the "day" word does not fix it:

>>> print(dateparser.parse("the 1st day of last month"))
2025-03-04 19:31:12.496695
>>> 
@sglebs
Copy link
Author

sglebs commented Apr 5, 2025

"this month " also does not work:

>>> print(dateparser.parse("the 1st of this month"))
2025-04-05 19:34:11.876075
>>> print(dateparser.parse("the 1st of the month"))
2025-03-05 19:34:25.675231
>>> 

@sglebs
Copy link
Author

sglebs commented Apr 5, 2025

https://github.com/bear/parsedatetime is able to parse it:

>>> import parsedatetime
>>> cal = parsedatetime.Calendar()
>>> cal.parse("the 1st day of last month")
(time.struct_time(tm_year=2025, tm_mon=3, tm_mday=1, tm_hour=9, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=60, tm_isdst=-1), 1)
>>> cal.parse("the 1st day of last month at midnight")
(time.struct_time(tm_year=2025, tm_mon=3, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=60, tm_isdst=-1), 3)
>>> 

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

No branches or pull requests

1 participant