go-ruby-date

Ruby's Date & DateTime in pure Go — MRI-compatible, no cgo.

pure Go · zero cgo MRI-compatible Julian-day model Gregorian reform strftime parse · strptime week-date · ordinal MRI byte-exact 100% coverage 6 arches
Documentation GitHub
Documentation (MkDocs Material + mike) License: BSD-3-Clause Go 1.26.4+ Coverage 100%

go-ruby-date is a pure-Go (no cgo) reimplementation of Ruby's Date and DateTime — built on the astronomical Julian-day model Ruby itself uses, with the configurable Julian→Gregorian reform, full strftime formatting, heuristic parse and format-driven strptime, and ISO week-date and ordinal arithmetic — matching reference Ruby byte-for-byte. It was extracted from rbgo's prelude/internals into a reusable standalone library: no dependency on the Ruby runtime, the dependency runs the other way. It is the date backend for go-embedded-ruby, bound by rbgo as a native module just like go-ruby-regexp and go-ruby-erb — differential-tested against MRI, 100% coverage, CI green across 6 arches and 3 OSes.

Julian-day model ready

Dates represented by astronomical Julian day number, the same internal model Ruby’s Date uses, so arithmetic and conversions match exactly.

Julian→Gregorian reform ready

The configurable reform date (default Italian 1582-10-15), with the missing-days gap handled the way reference Ruby handles it.

strftime formatting ready

The full directive set (%Y %m %d %H %M %S %j %A %a %B %b %z …) producing byte-identical output to MRI’s Date#strftime.

parse & strptime ready

Heuristic Date.parse and format-driven Date.strptime, accepting the same inputs and raising on the same malformed ones as reference Ruby.

Week-date & ordinal arithmetic ready

ISO week-date (%G/%V), ordinal (day-of-year) construction, and day/month arithmetic with Ruby’s rollover semantics.

Differential oracle & coverage ready

A wide date corpus formatted and parsed both here and by the system ruby/date, compared byte-for-byte; 100% coverage, gofmt + go vet clean, green across all six 64-bit Go arches and three OSes.

A faithful port of Ruby's Date and DateTime in pure Go, cgo disabled, so it cross-compiles and embeds anywhere. It models dates by Julian day number, honours the Julian→Gregorian reform, formats with the full strftime directive set, parses via parse and strptime, and does ISO week-date and ordinal arithmetic. Validated differentially against the system ruby binary — formatted strings and parsed values compared against Date/DateTime. It is a standalone, reusable module extracted from rbgo's internals, and the date backend for the sibling org github.com/go-embedded-ruby.