Convert TODAY and NOW to the workbook date system in 1904 workbooks (#578)

This commit is contained in:
MarekSpodBiedry
2026-10-12 08:34:40 +02:00
parent 3926d21aa9
commit ff14224ff9
6 changed files with 35 additions and 10 deletions
+8
View File
@@ -59,6 +59,14 @@ pub fn serial_from_unix_ms(ms: f64) -> f64 {
25569.0 + ms / 86_400_000.0
}
/// Converts a 1900-system serial (as the clock supplies it) to the serial of the same instant in `sys`.
pub fn serial_in_system(sys: DateSystem, serial_1900: f64) -> f64 {
match sys {
DateSystem::D1900 => serial_1900,
DateSystem::D1904 => serial_1900 - 1462.0,
}
}
pub fn civil_from_days(z: i64) -> (i32, u32, u32) {
let z = z + 719468;
let era = if z >= 0 { z } else { z - 146096 } / 146097;