Repository navigation
Releases: hebcal/greg
Release list
v1.1.0
Performance and documentation release. No API changes — every exported function keeps its existing name, signature, and behavior.
⚠️ Minimum Go version is now 1.18 (was 1.13)
The only change that can affect consumers. Nothing in the library uses a language feature newer than 1.13; the floor was raised so the module works with current tooling. If you build with Go 1.18 or later, no action is needed.
Performance
Conversions were treating the exported GREG_ADJUSTMENT_BEGIN/END time.Time values as numbers, calling .Year(), .Month() and .Day() on every call — each one a timezone lookup plus a full calendar decomposition. ToRD did up to six of them, and FromRD recomputed a fixed constant from scratch on every call. Those are now integer constants.
The float64 mod/quotient helpers were also replaced with exact integer floor division, and the calendar-cycle math now does one division where it previously did two.
| before | after | ||
|---|---|---|---|
ToRD |
416 ns | 6.7 ns | −98% |
FromRD |
1121 ns | 14.8 ns | −99% |
DateToRD |
323 ns | 15.3 ns | −95% |
IsLeapYear |
71.9 ns | 1.7 ns | −98% |
DaysIn |
72.1 ns | 1.8 ns | −97% |
| round trip | 1557 ns | 20.1 ns | −99% |
Still zero allocations. ProlepticToRD is ~1.9 ns slower (4.4 → 6.3 ns), the cost of exact integer math over math.Floor; the round trip is faster, which is the path that matters in practice.
Documentation
- The package doc was detached from the
packageclause by a stray blank line, so pkg.go.dev was showing the wrong comment. Fixed. - README now explains the difference between the Gregorian/Julian functions and the Proleptic ones: the missing 11 days of September 1752, the Julian leap year rule before 1752 (1700 is a leap year), and that
ToRDhas no year 0 whileProlepticToRDdoes. - Examples expanded from 6 to 14, including a package-level example so pkg.go.dev opens with runnable code.
Testing
Behavior is unchanged, and verified as such: an exhaustive round-trip test over 1.8M R.D. values (covering the Julian period, the 1752 transition, and dates BCE), plus a differential test proving the new integer helpers match the previous float64 implementations exactly. CI now runs a [1.18, stable] matrix with go vet, replacing a pin to Go 1.13.
Full changelog: v1.0.2...v1.1.0
1.0.2
1.0.1
What's Changed
- Use Julian calendar for dates before September 14, 1752 by @Isaac-D-Cohen in #2
New Contributors
- @Isaac-D-Cohen made their first contribution in #2
Full Changelog: v1.0.0...v1.0.1