Files
openchamber/packages/ui/src/lib/timeFormat.ts
T
00821700de chore: remove dead code (59 unused files + ~125 unused exports) (#1835)
* chore: remove dead/unreferenced files across ui, vscode

Remove 59 unused source files (components, hooks, lib utils, stores,
barrels, and orphaned vscode github modules) that are not imported by
any entry-reachable code. Also drop a stale test mock for the removed
execCommands module.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* refactor: remove unused exported symbols (types, functions, consts, hooks)

Remove exported symbols whose identifier is referenced nowhere in the
repository (verified via repo-wide search), across ui types/contracts,
lib utilities, sync layer, stores, and components. Also drop the few
imports/private helpers orphaned by these removals.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* refactor: remove more unused exports (desktop, shortcuts, worktree, vscode)

Continue removing repo-wide unreferenced exported functions, consts and
types across lib/desktop, shortcuts, worktreeSessionCreator, sync, and
vscode gitService, with cascading orphaned helpers/imports cleaned up.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* chore: add dead-code cleanup tooling

* refactor: checkpoint dead-code cleanup

* refactor: remove dead-code suppressions

---------

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-06-26 19:27:53 +03:00

45 lines
1.4 KiB
TypeScript

import { getCurrentIntlLocale } from '@/lib/i18n';
import type { TimeFormatPreference } from '@/stores/useUIStore';
type TimePrecision = 'minute' | 'second';
const getHour12Option = (preference: TimeFormatPreference): boolean | undefined => {
if (preference === '12h') return true;
if (preference === '24h') return false;
return undefined;
};
export const formatTimeForPreference = (
timestamp: number | Date,
preference: TimeFormatPreference,
options: { precision?: TimePrecision; hour?: 'numeric' | '2-digit'; fallback?: string } = {},
): string => {
const date = timestamp instanceof Date ? timestamp : new Date(timestamp);
if (!Number.isFinite(date.getTime())) {
return options.fallback ?? '';
}
return date.toLocaleTimeString(getCurrentIntlLocale(), {
hour: options.hour ?? 'numeric',
minute: '2-digit',
second: options.precision === 'second' ? '2-digit' : undefined,
hour12: getHour12Option(preference),
});
};
export const formatDateTimeForPreference = (
timestamp: number | Date,
preference: TimeFormatPreference,
options: Intl.DateTimeFormatOptions,
): string => {
const date = timestamp instanceof Date ? timestamp : new Date(timestamp);
if (!Number.isFinite(date.getTime())) {
return '';
}
return date.toLocaleString(getCurrentIntlLocale(), {
...options,
hour12: options.hour ? getHour12Option(preference) : options.hour12,
});
};