go-dateparser
go-dateparser copied to clipboard
Parsing day of week gives bad result if previous occurrence of that day was in last month
When parsing dates that only include day of week, the result is correct if the intended result is in this month, but shows the wrong month (current month) if the intended result is in the previous month.
For example:
cfg := &dateparser.Configuration{
DefaultTimezone: time.Local,
CurrentTime: time.Date(2025, 4, 1, 12, 0, 0, 0, time.Local),
}
t, _ := dateparser.Parse(cfg, "Wednesday")
fmt.Println(t)
will print {en Day 2025-04-26 00:00:00 +0200 CEST} (which is not even a Wednesday).
The correct result would be {en Day 2025-03-26 00:00:00 +0200 CEST}
I believe the error happens at internal/parser/absolute/parser.go:560