@gj-kit/format recipes
Each code block reuses a public-contract example already type-checked in the package README.
1. Format a timestamp with an explicit timezone
Section titled “1. Format a timestamp with an explicit timezone”Keep timezone and separator beside the display call so screens cannot inherit different defaults.
Outcome: A stable display label whose timezone and separator are explicit at the call site.
Application-owned boundary: Choose the timezone and separator in code; do not let persisted or operational values inherit device defaults.
import { formatDateTime } from '@gj-kit/format';
export const dateLabel = formatDateTime(Date.UTC(2026, 7, 26, 0, 0), { timeZone: 'Asia/Seoul', separator: '-',});2. Format money and bytes without hidden meaning
Section titled “2. Format money and bytes without hidden meaning”Select currency and zero-value behavior in code rather than allowing a formatter to guess policy.
Both @ts-expect-error lines hold against the published dist/index.d.ts under strict + exactOptionalPropertyTypes, and fallback: null widens the return type to exactly string | null.
import { formatBytes, formatDateTime, parseIsoInstant } from '@gj-kit/format';
declare const createdAt: string; // app-owned: an ISO string straight off the API
// @ts-expect-error 'GB' labels a decimal divisor, but 'binary' divides by 1024.formatBytes(1, { system: 'binary', maxUnit: 'GB', unitSpace: true, nonPositive: 'render' });
// @ts-expect-error a wall-clock string never reaches a formatter — parse it first.formatDateTime(createdAt, { timeZone: 'Asia/Seoul', separator: '-' });
const instant = parseIsoInstant(createdAt, { assumeNoOffset: 'utc' });
export const stamp: string = formatDateTime(instant, { timeZone: 'Asia/Seoul', separator: '-' });
// fallback widens the return type by exactly what you passed, and nothing more.export const sizeChip: string | null = formatBytes(0, { system: 'decimal', unitSpace: false, nonPositive: 'fallback', fallback: null,});Use the complete API reference for every export and import path.