MCPcopy
hub / github.com/date-fns/date-fns / getRoundingMethod

Function getRoundingMethod

pkgs/core/src/_lib/getRoundingMethod/index.ts:3–10  ·  view source on GitHub ↗
(method: RoundingMethod | undefined)

Source from the content-addressed store, hash-verified

1import type { RoundingMethod } from "../../types.ts";
2
3export function getRoundingMethod(method: RoundingMethod | undefined) {
4 return (number: number) => {
5 const round = method ? Math[method] : Math.trunc;
6 const result = round(number);
7 // Prevent negative zero
8 return result === 0 ? 0 : result;
9 };
10}

Callers 9

differenceInWeeksFunction · 0.90
test.tsFile · 0.90
differenceInSecondsFunction · 0.90
differenceInMinutesFunction · 0.90
roundToNearestMinutesFunction · 0.90
differenceInQuartersFunction · 0.90
formatDistanceStrictFunction · 0.90
roundToNearestHoursFunction · 0.90
differenceInHoursFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected