BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/efferd/formater

formater

efferd-/formater
FreeComponent

Formater utilities.

Live preview

live · rendered by the registry
Rendered by efferd on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add http://efferd.com/r/formater.json

Source

lib/formater.tsefferd.com/r/formater.json
1/** Shared locale for dashboard (charts, KPIs, tables). */
2export const DASHBOARD_LOCALE = "en-US";
3
4/** Noon anchor avoids off-by-one labels around timezone boundaries for ISO date strings. */
5export function parseIsoCalendarDate(isoDate: string): Date {
6 return new Date(`${isoDate}T12:00:00`);
7}
8
9export type DashboardDateStyle = "month" | "day-month" | "full";
10
11export function formatDate(isoDate: string, style: DashboardDateStyle): string {
12 const date = parseIsoCalendarDate(isoDate);
13 if (style === "month") {
14 return date.toLocaleDateString(DASHBOARD_LOCALE, { month: "short" });
15 }
16 if (style === "day-month") {
17 return date.toLocaleDateString(DASHBOARD_LOCALE, {
18 day: "numeric",
19 month: "short",
20 });
21 }
22 return date.toLocaleDateString(DASHBOARD_LOCALE, {
23 day: "numeric",
24 month: "short",
25 year: "numeric",
26 });
27}
28
29/** X-axis for range charts: weekday when showing ~a week, otherwise month + day. */
30export function formatChartAxisTick(
31 isoDate: string,
32 periodDays: number
33): string {
34 const date = parseIsoCalendarDate(isoDate);
35 if (periodDays <= 7) {
36 return date.toLocaleDateString(DASHBOARD_LOCALE, { weekday: "short" });
37 }
38 return formatDate(isoDate, "day-month");
39}
40
41export type ChartTooltipWeekdayStyle = "short" | "long";
42
43/** Tooltip label for a chart point (weekday + month + day). */
44export function formatChartTooltipDate(
45 isoDate: string,
46 weekdayStyle: ChartTooltipWeekdayStyle = "short"
47): string {
48 const date = parseIsoCalendarDate(isoDate);
49 return date.toLocaleDateString(DASHBOARD_LOCALE, {
50 weekday: weekdayStyle,
51 day: "numeric",
52 month: "short",
53 });
54}
55
56export function formatCompactCurrency(
57 value: number,
58 options?: { maximumFractionDigits?: number }
59) {
60 const { maximumFractionDigits = 0 } = options ?? {};
61 return new Intl.NumberFormat(DASHBOARD_LOCALE, {
62 currency: "USD",
63 maximumFractionDigits,
64 notation: "compact",
65 style: "currency",
66 }).format(value);
67}
68
69/** Full-precision USD (e.g. average order value). */
70export function formatFullCurrency(value: number) {
71 return new Intl.NumberFormat(DASHBOARD_LOCALE, {
72 currency: "USD",
73 minimumFractionDigits: 2,
74 maximumFractionDigits: 2,
75 style: "currency",
76 }).format(value);
77}
78
79export function formatCompactNumber(value: number) {
80 return new Intl.NumberFormat(DASHBOARD_LOCALE, {
81 maximumFractionDigits: 1,
82 notation: "compact",
83 }).format(value);
84}
85
86/** Whole numbers with grouping (visits, sessions, counts). */
87export function formatInteger(value: number) {
88// … truncated

Files it writes

  • lib/formater.ts

Facts

Registry
efferd
Type
registry:component
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
today

Go to the source

Docs on efferd efferd.com Raw registry item This item as JSON

More from efferd

All 201 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
apple-iconapple-iconefferdComponentsFreeno deps
auth-dividerauth-dividerefferdComponentsFreeno deps
copy-buttoncopy-buttonefferdComponentsFreeno deps
decor-icondecor-iconefferdComponentsFreeno deps
discord-icondiscord-iconefferdComponentsFreeno deps
facebook-iconfacebook-iconefferdComponentsFreeno deps
figma-iconfigma-iconefferdComponentsFreeno deps
framer-iconframer-iconefferdComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex