-
Notifications
You must be signed in to change notification settings - Fork 467
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
Parsing plain year numbers like "2024" with "PREFER..."-settings set to "last" returns wrong date. 1 day missing... #1228
Comments
Same problem here on windows, using only |
I am also experiencing this with the following minimal code on import dateparser
dateparser_settings = {
"PREFER_MONTH_OF_YEAR": (
"last"
),
"PREFER_DAY_OF_MONTH": (
"last"
),
"PARSERS": ["absolute-time"],
}
value = "2024"
parsed_date = dateparser.parse(
value, settings=dateparser_settings
) # output: datetime.datetime(2024, 12, 30, 0, 0) |
Investigating a bit more and testing it with Code: import time_machine
for month in range(1,13):
travel_date = f"2024-{month}-15"
with time_machine.travel(travel_date):
import dateparser
dateparser_settings = {
"PREFER_MONTH_OF_YEAR": (
"last"
),
"PREFER_DAY_OF_MONTH": (
"last"
),
"PARSERS": ["absolute-time"],
}
value = "2024"
parsed_date = dateparser.parse(
value, settings=dateparser_settings
)
print(f"Current date: {travel_date}. Last year date: {parsed_date}") Output:
|
@lluissalord : That's a perfect proof for a funny bug! Thx |
It seems you're skipping a day. It should be 2024-12-31 00:00:00
...running on Macbook Air M2, Python 3.11 with
The text was updated successfully, but these errors were encountered: