UNPKG

@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.

23 lines • 1.22 kB
import { Temporal } from "./temporal.js"; /** * Read `roundingIncrement` and `roundingMode` the way Temporal does, for a rounding GMT computes * itself (a date unit that Temporal's own `round()` does not accept). * * - `roundingIncrement` follows GetRoundingIncrementOption: `undefined` is 1; any other value is * truncated towards zero (ToIntegerWithTruncation), and a non-finite value or one below 1 after * truncation is rejected. * - `roundingMode` follows GetRoundingModeOption: `undefined` is `"halfExpand"`; a value outside the * nine modes is rejected. * * @param roundingIncrement caller-supplied increment * @param roundingMode caller-supplied rounding mode * @returns the resolved increment and mode, or null when Temporal would throw a RangeError * * @example resolveManualRoundingOptions(1.5, undefined) // { increment: 1, mode: "halfExpand" } * @example resolveManualRoundingOptions(0.9, "floor") // null * @example resolveManualRoundingOptions(2, "bogus" as never) // null */ export declare function resolveManualRoundingOptions(roundingIncrement: number | undefined, roundingMode: Temporal.RoundingMode | undefined): { increment: number; mode: Temporal.RoundingMode; } | null;