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
+9 -1
View File
@@ -391,7 +391,7 @@ pub struct HfContext {
/// Today's date and the current time as headers and footers show them (`&D`, `&T`).
pub fn hf_date_time(wb: &Workbook) -> (String, String) {
let now = gridcraft_calc::now_serial();
let now = gridcraft_core::date::serial_in_system(wb.date_system, gridcraft_calc::now_serial());
let date = crate::display::format(&Value::Number(now.floor()), "m/d/yyyy", wb).text;
let time = crate::display::format(&Value::Number(now), "h:mm AM/PM", wb).text;
(date, time)
@@ -1765,6 +1765,14 @@ mod tests {
}
}
#[test]
fn header_footer_date_follows_the_workbook_date_system() {
let mut wb = Workbook::new();
let date_1900 = hf_date_time(&wb).0;
wb.date_system = gridcraft_core::DateSystem::D1904;
assert_eq!(hf_date_time(&wb).0, date_1900);
}
#[test]
fn header_footer_section_edits_are_undoable_and_views_are_per_sheet() {
let mut s = s();