Durations past 24 hours and the basic date/time functions
- New cell format "Dauer" ([h]:mm): hours keep counting past 24 (37:30). A formula left on "Automatisch" whose numeric inputs are all times or durations (=SUM over working times, =end-start) displays as a duration. Typing 24 or more hours (37:30) enters a duration. - "Datum + Zeit" shows a bare time of day (< 1 day) without the epoch date 30.12.1899. - New functions: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, WEEKDAY, ISOWEEKNUM, WEEKNUM, EDATE, EOMONTH, DAYS, DATEDIF, NETWORKDAYS, WORKDAY, DATEVALUE, TIMEVALUE. Where Excel defaults to US conventions, ISO 8601 is the default: weeks start Monday (WEEKDAY -> Monday = 1), WEEKNUM is the ISO week. Excel's other types stay available. - Command reference and README document all of it; the README test count is updated to 553. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+26
-5
@@ -62,6 +62,7 @@ import type {
|
||||
ButtonObject,
|
||||
CellCoord,
|
||||
CellFormat,
|
||||
CellNumFmt,
|
||||
CellGraphNode,
|
||||
ChartObject,
|
||||
CustomFunction,
|
||||
@@ -1767,11 +1768,31 @@ function createStore() {
|
||||
return wb.cellValue(tableId, col, row);
|
||||
}
|
||||
function cellDisplay(tableId: string, col: number, row: number): string {
|
||||
return formatValue(
|
||||
cellValue(tableId, col, row),
|
||||
effectiveLocale(tableId),
|
||||
tableById(tableId)?.formats?.[`${col},${row}`]?.numFmt ?? 'auto',
|
||||
);
|
||||
return formatValue(cellValue(tableId, col, row), effectiveLocale(tableId), displayNumFmt(tableId, col, row));
|
||||
}
|
||||
/** The cell's number format, or -- for a formula cell left on "auto" -- a
|
||||
* format inferred from what it computes with: a formula whose numeric
|
||||
* inputs are all times/durations (`=SUM(B2:B8)`, `=C2-B2` over clock
|
||||
* times) shows as a duration, so a total of 37.5 hours reads `37:30`
|
||||
* instead of wrapping to `13:30` or showing the raw day fraction. Walks
|
||||
* formula chains (a sum of sums), bounded by `budget` cells visited. */
|
||||
function displayNumFmt(
|
||||
tableId: string,
|
||||
col: number,
|
||||
row: number,
|
||||
budget = { left: 2000 },
|
||||
): CellNumFmt {
|
||||
const explicit = tableById(tableId)?.formats?.[`${col},${row}`]?.numFmt ?? 'auto';
|
||||
if (explicit !== 'auto' || !cellInput(tableId, col, row).startsWith('=')) return explicit;
|
||||
let sawTime = false;
|
||||
for (const p of wb.graphPrecedents(tableId, col, row)) {
|
||||
if (--budget.left < 0) return 'auto';
|
||||
if (typeof wb.cellValue(p.tableId, p.col, p.row) !== 'number') continue;
|
||||
const f = displayNumFmt(p.tableId, p.col, p.row, budget);
|
||||
if (f !== 'time' && f !== 'duration') return 'auto';
|
||||
sawTime = true;
|
||||
}
|
||||
return sawTime ? 'duration' : 'auto';
|
||||
}
|
||||
|
||||
// ---- number-format locale (object -> sheet -> document cascade) ---
|
||||
|
||||
Reference in New Issue
Block a user