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:
@@ -133,6 +133,35 @@ describe('seed document acceptance (canvas model)', () => {
|
||||
expect(s.canUndo.value).toBe(false);
|
||||
});
|
||||
|
||||
it('a formula over times shows as a duration, past 24 hours', () => {
|
||||
const s = fresh();
|
||||
s.newDocument();
|
||||
const t = tableId(s, 'Tabelle 1');
|
||||
setCell(s, 'Tabelle 1', 'A1', '08:30');
|
||||
setCell(s, 'Tabelle 1', 'A2', '09:15');
|
||||
setCell(s, 'Tabelle 1', 'A3', '20:00');
|
||||
setCell(s, 'Tabelle 1', 'A4', '=SUM(A1:A3)');
|
||||
setCell(s, 'Tabelle 1', 'B1', '=A2-A1');
|
||||
setCell(s, 'Tabelle 1', 'B2', '=A4+B1'); // chain: a sum of formulas
|
||||
expect(s.cellDisplay(t, 0, 3)).toBe('37:45');
|
||||
expect(s.cellDisplay(t, 1, 0)).toBe('00:45');
|
||||
expect(s.cellDisplay(t, 1, 1)).toBe('38:30');
|
||||
// an explicit format always wins over the inferred one
|
||||
s.setRangeFormat(t, { col: 0, row: 3 }, { col: 0, row: 3 }, { numFmt: 'time' });
|
||||
expect(s.cellDisplay(t, 0, 3)).toBe('13:45');
|
||||
});
|
||||
|
||||
it('a typed 24+ hour time becomes a duration; dates are not durations', () => {
|
||||
const s = fresh();
|
||||
s.newDocument();
|
||||
const t = tableId(s, 'Tabelle 1');
|
||||
setCell(s, 'Tabelle 1', 'A1', '37:30');
|
||||
expect(s.cellDisplay(t, 0, 0)).toBe('37:30');
|
||||
setCell(s, 'Tabelle 1', 'C1', '2026-09-02');
|
||||
setCell(s, 'Tabelle 1', 'C2', '=C1+30');
|
||||
expect(s.cellDisplay(t, 2, 1)).not.toContain(':');
|
||||
});
|
||||
|
||||
it('inserting a new table and referencing it across sheets works', () => {
|
||||
const s = fresh();
|
||||
const sheet2 = s.doc.sheets[1].id;
|
||||
|
||||
Reference in New Issue
Block a user