Skip to content

fix(datetime): correct divisor in civil_from_days (1461 → 1460)#1190

Open
cyrilgandon wants to merge 1 commit into
fortran-lang:masterfrom
cyrilgandon:fix/civil_from_days_leap_years
Open

fix(datetime): correct divisor in civil_from_days (1461 → 1460)#1190
cyrilgandon wants to merge 1 commit into
fortran-lang:masterfrom
cyrilgandon:fix/civil_from_days_leap_years

Conversation

@cyrilgandon

@cyrilgandon cyrilgandon commented Jun 22, 2026

Copy link
Copy Markdown

Fixing #1189

I noticed that the yoe (year of era) computation in src/stdlib_datetime.f90 differs from Howard Hinnant's reference algorithm (date_algorithms).

Reference:

const unsigned yoe = (doe - doe/1460 + doe/36524 - doe/146096) / 365; // [0, 399]

Current code in stdlib_datetime.f90:

yoe = (doe - doe/1461 + doe/36524 - doe/146096) / 365

The divisor differs: 1460 in the reference versus 1461 here.

@cyrilgandon cyrilgandon force-pushed the fix/civil_from_days_leap_years branch 2 times, most recently from 1c45787 to 0408d10 Compare June 23, 2026 07:19

@jalvesz jalvesz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @cyrilgandon thanks for finding and fixing this.

@cyrilgandon

Copy link
Copy Markdown
Author

There seems to be an issue with the code coverage report. I'm not sure what the right fix is, so I'll leave it to the maintainer to handle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants