days_from_civil

std.elementwise.days_from_civil · Level L4

Days since 1970-01-01 for a date of the proleptic Gregorian calendar, by Howard Hinnant's algorithm: the year is counted from March, so the leap day falls last, and every division is a floor.

era·146097 + doe − 719468, era = ⌊y′/400⌋

Signature

days_from_civil(year: i64[n], month: i64[n], day: i64[n]) → i64[n]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

14monthi64[n]yeari64[n]9dayi64[n]1Subtractt1412Addm9Subtractd0FloorDivjan_febModmp153Subtracty4002Multiplymp1535Addmp153_2FloorDivera146097Multiplyera400FloorDivmonth_daysMultiplyera_days365Subtractyoe4100AdddoyMultiplyyoe365FloorDivleaps4FloorDivleaps100Adddoe1Subtractdoe2Adddoe719468AddtotalSubtractdaysdaysi64[n]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference (date(year, month, day) - date(1970, 1, 1)).days in exact rational arithmetic, on all 40 test cases.
  • All 174 int64 results are exact: the error is zero.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the int64 nearest the exact value)
100%
bit-equal to the NumPy formula in int64
100%
largest error, in units in the last place
0

Note

The reference is Python's own datetime, a different implementation, over years 1–9999.

Identity

Calls
—
Called by
—
sha256:adaa82e9d68f92decc57b0ef39e5bdf4fc1c72760b6e9408472193eb96d23c3f

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.