Skip to content

relativeBucket — @gj-kit/format

A public function from @gj-kit/format. The signature below is taken directly from the 0.1.1 release declaration.

import { relativeBucket } from '@gj-kit/format';
/**
* Pure bucket selection against an explicit clock. Returns null for
* null/undefined/invalid input. Thresholds: <60s just-now, <60m minutes,
* <24h hours, <30d days, <12mo months, then years.
*
* Calendar-unaware by construction: a month is exactly 30 days and a year is
* exactly 12 such months — 360 days, not 365. This reproduces both source apps
* bit for bit; the drift is a systematic early promotion of about five days per
* year, so `days = 360` already renders as one year.
*/
declare function relativeBucket(value: FormatDateInput | null | undefined, now: Date): FormatRelativeBucket | null;

This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.

  • Package: @gj-kit/format
  • Version: 0.1.1
  • Public entry: .
  • Source: GitHub