All contributions

olebedev/when

olebedev/when

A natural language date and time parser in Go with pluggable rules.

Language
Go
GitHub stars
1,465
Merged changes
1

What we changed

Month parsing no longer overflows into the next month when the reference date's day is larger than the target month allows.

What this work shows

  • Date normalisation in Go's time.Date
  • Natural language date parsing
  • Regression tests with testify
What was broken

september 5th gave 5 October

With 31 October as the reference date, september 5th gave 5 October and february 11 gave 11 March. Context.Time set the new month with the reference date's day, and time.Date rolled the non-existent 31 September over to 1 October before the parser applied the right day.

How we fixed it

The day is clamped to the month's length

Before the month changes, the reference day is clamped to the target month's last day by a new daysIn helper. The bare text september now gives 30 September, and the TestExactMonthDateFromLongMonth test parses against 31 October.

#50

Merged change 1

  1. #50 Fix month parsing overflowing into the next month Merged 27 September 2026

What it taught us

A bug that only shows up on certain days of the month slips past the usual tests. It takes a test with a reference date that reproduces it to catch it.

More about this technology: Golang

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.