fromPgMicroseconds
Signature
Section titled “Signature”fromPgMicroseconds(value: bigint): stringConvert PostgreSQL’s internal timestamptz value back to an ISO 8601 instant string.
valueis a signed count of microseconds since 2000-01-01T00:00:00Z, the number PostgreSQL stores and the binary wire format carries. It is not a Unix timestamp.- Accepted range is the narrower of PostgreSQL’s and
Temporal.Instant’s, one binding at each end:-211813488000000000n(MIN_TIMESTAMP,-004713-11-24T00:00:00Z— the manual’s “4713 BC”, counted in the Julian calendar) up to8639053315200000000n(+275760-09-13, whereTemporalstops, well before PostgreSQL’s 294276 AD). Anything outside returns "". - Exact in this direction — a microsecond is coarser than the nanoseconds an ISO string carries, so nothing is rounded. The loss, if any, happened in
toPgMicroseconds. - Returns "" on invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | bigint | microseconds since 2000-01-01 (bigint) |
Returns
Section titled “Returns”ISO 8601 instant string (UTC), or "" on invalid input
Examples
Section titled “Examples”import { fromPgMicroseconds } from "@northguild/gmt/precision/convert";
fromPgMicroseconds(0n) // "2000-01-01T00:00:00Z" — the PostgreSQL epoch