Page MenuHomeFreeBSD

strptime: Fix day-of-week calculation.
ClosedPublic

Authored by des on Dec 7 2024, 1:35 PM.
Tags
None
Referenced Files
F149678776: D47977.id147678.diff
Thu, Mar 26, 5:18 AM
F149620726: D47977.id147678.diff
Wed, Mar 25, 5:42 PM
Unknown Object (File)
Mon, Mar 23, 8:14 AM
Unknown Object (File)
Mon, Mar 23, 3:34 AM
Unknown Object (File)
Fri, Mar 20, 3:30 PM
Unknown Object (File)
Mon, Mar 16, 4:27 PM
Unknown Object (File)
Sat, Mar 14, 10:28 PM
Unknown Object (File)
Tue, Mar 10, 10:02 AM
Subscribers

Details

Summary

The day-of-week calculation used the raw year value without adjusting
for TM_YEAR_BASE, so it was off by one for 300 years out of every 400;
it just happened to be correct for 1901 through 2000. It also used a
loop where a simple addition would have sufficed.

While here, simplify our version of Gauss's algorithm, and document
that we assume the Gregorian calendar.

MFC after: 1 week
PR: 282916

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Dec 7 2024, 1:35 PM
This revision is now accepted and ready to land.Dec 7 2024, 1:59 PM

Looks good! Thank you for the test case. :-)

This revision was automatically updated to reflect the committed changes.