fromDotNetTicks
Signature
Section titled “Signature”fromDotNetTicks(value: bigint): stringConvert .NET DateTime.Ticks back to an ISO 8601 instant string.
valuecounts 100-nanosecond intervals since 0001-01-01T00:00:00 in the proleptic Gregorian calendar.- Only UTC ticks name an instant. .NET counts
Ticksin the zone of theDateTime’sKind: aLocalorUnspecifiedvalue counts local wall-clock time, and this function reads every value as UTC. PassDateTime.UtcNow.TicksorToUniversalTime().Ticks;DateTime.Now.Tickson a UTC−5 host decodes five hours early. - Accepts
DateTime.MinValue(0n) toDateTime.MaxValue(3155378975999999999n, 9999-12-31T23:59:59.9999999). A tick count outside that is not aDateTime, and a negative value in particular is rejected rather than read as a pre-year-1 instant. - Pass
Ticks, not the raw backing field: .NET packsDateTimeKindinto its top two bits, and aKind-tagged value would decode as an instant thousands of years out. - 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
toDotNetTicks. - Returns "" on invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | bigint | 100-nanosecond intervals since 0001-01-01 (bigint, 0n to 3155378975999999999n) |
Returns
Section titled “Returns”ISO 8601 instant string (UTC), or "" on invalid input
Examples
Section titled “Examples”import { fromDotNetTicks } from "@northguild/gmt/precision/convert";
fromDotNetTicks(0n) // "0001-01-01T00:00:00Z" — DateTime.MinValue