fromExcelSerial
Signature
Section titled “Signature”fromExcelSerial(value: number, options?: { system?: ExcelDateSystem; }): stringConvert an Excel day serial back to an ISO 8601 instant string.
- The serial is days with the time of day as the fraction, read as a UTC wall clock.
- Serial 60 in the 1900 system returns "" — it is the phantom 29 February 1900, a date that never existed. Lotus 1-2-3 treated 1900 as a leap year and Excel keeps the bug for compatibility, so the whole serial day
[60, 61)is a hole: 59 is 1900-02-28 and 61 is 1900-03-01. Mapping 60 to either neighbour would put every earlier date one day out. - In the 1904 system serial 60 is a real 1904-03-01.
- Accepted range is Excel’s own: serial 1 (1900-01-01) to just under 2958466 (the end of 9999-12-31) in the 1900 system, serial 0 to just under 2957004 in the 1904 system. Serial 0 in the 1900 system is Excel’s “January 0, 1900” placeholder, not a date.
- Rounds to the nearest millisecond. A serial is a
double, whose resolution is about a microsecond near 2024 and about 40 µs near 9999 — finer than a millisecond nowhere in the range, so rounding there is what makes the round trip throughtoExcelSerialexact. - Returns "" on invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | number | Excel day serial (number, may carry a fractional time of day) |
Options
Section titled “Options”options
Which Excel date system the serial is in
| Option | Type | Default | Description |
|---|---|---|---|
system? | "1900" | "1904" (ExcelDateSystem) | "1900" | Which Excel date system the serial is counted in. "1900" counts serial 1 as 1900-01-01 and has the phantom serial 60; "1904" is the legacy Mac system, whose serial 0 is 1904-01-01 and which has no phantom day. The same instant is exactly 1462 lower in the 1904 system. |
Returns
Section titled “Returns”ISO 8601 instant string (UTC), or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { fromExcelSerial } from "@northguild/gmt/precision/convert";
fromExcelSerial(1) // "1900-01-01T00:00:00Z" — Excel's first serial