@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
15 lines • 909 B
TypeScript
import { FractionalDigit } from "../types/fractional-digit.js";
import "../types/index.js";
/**
* Resolve how many fractional second digits a result snapped to `unit` is printed with.
*
* - An explicit `fractionalSecondDigits` always wins — including an invalid one, which Temporal's
* `toString` then rejects, so the caller returns its sentinel. Only an omitted member defaults.
* - Otherwise 3 for "millisecond", 6 for "microsecond", 9 for "nanosecond", and 0 for anything
* coarser (or unrecognised), so the output never hides the precision the unit asked for.
*
* @param unit the unit the value was snapped or rounded to
* @param fractionalSecondDigits optional caller-supplied override
* @returns the digit count to pass to `toString({ fractionalSecondDigits })`
*/
export declare function defaultFractionalDigits(unit: string, fractionalSecondDigits?: FractionalDigit): FractionalDigit;