toFileTime
Signature
Section titled “Signature”toFileTime(isoString: string): bigintConvert an ISO 8601 instant string to a Windows FILETIME.
- A
FILETIMEcounts 100-nanosecond intervals since 1601-01-01T00:00:00Z. The Unix delta is 11 644 473 600 seconds, i.e.116444736000000000nticks. - Sub-100 ns digits floor away, toward negative infinity, so the tick grid stays uniform either side of the epoch. Reach for
truncateNanosecondsfirst if the caller needs to see the loss. - The range is the format’s own, and instants outside it are invalid input, not a negative tick count. The range is
0nto2^63 − 1— 1601-01-01 to+030828-09-14T02:48:05.4775807Z. The struct’s twoDWORDs could hold more, but Microsoft’sFileTimeToSystemTimerequires a value “less than 0x8000000000000000”, andSetFileTimereserves2^64 − 1as a “do not modify” marker. Consumers commonly narrow this further: .NET’sDateTime.FromFileTimeUtcstops at 9999-12-31. - Returns
0non invalid input.0nis also the FILETIME epoch itself (1601-01-01) — validate the string first withisValidInstantwhen the two must be told apart.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
isoString | string | ISO 8601 instant string (e.g. “2024-03-10T12:00:00Z”) |
Returns
Section titled “Returns”100-nanosecond intervals since 1601-01-01 as a bigint, or 0n on invalid input
Examples
Section titled “Examples”import { toFileTime } from "@northguild/gmt/precision/convert";
toFileTime("1601-01-01T00:00:00Z") // 0n — the FILETIME epoch