Skip to content

fromFileTime

fromFileTime(value: bigint): string

Convert a Windows FILETIME back to an ISO 8601 instant string.

  • value counts 100-nanosecond intervals since 1601-01-01T00:00:00Z.
  • The accepted range is 0n to 2^63 − 1, 1601-01-01 to +030828-09-14T02:48:05.4775807Z. FILETIME is a pair of DWORDs, so a negative value is rejected rather than read as a pre-1601 instant. Values from 2^63 up are rejected too: Microsoft’s FileTimeToSystemTime requires a value “less than 0x8000000000000000”, and SetFileTime uses 0xFFFFFFFFFFFFFFFF (2^64 − 1) as its “do not modify” marker.
  • To decode the raw unsigned count anyway, for example to inspect a marker, compute fromNanoseconds((value - 116444736000000000n) * 100n).
  • Exact in this direction — 100 ns is coarser than the nanoseconds an ISO string carries, so nothing is rounded. The loss, if any, happened in toFileTime.
  • Returns "" on invalid input.
ParameterTypeDescription
valuebigint100-nanosecond intervals since 1601-01-01 (bigint, 0n to 2^63 − 1)

ISO 8601 instant string (UTC), or "" on invalid input

import { fromFileTime } from "@northguild/gmt/precision/convert";
fromFileTime(0n) // "1601-01-01T00:00:00Z" — the FILETIME epoch
output 

precision/convert/fromFileTime.ts