mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 18:09:40 +02:00
style: auto-format codebase with Prettier
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
This commit is contained in:
parent
0241f5554c
commit
d36b321d9d
3952 changed files with 661498 additions and 739751 deletions
|
|
@ -6,8 +6,8 @@ import { format, formatDistanceToNow, parseISO, isToday, isYesterday } from 'dat
|
|||
import { de, enUS } from 'date-fns/locale';
|
||||
|
||||
const locales = {
|
||||
de,
|
||||
en: enUS,
|
||||
de,
|
||||
en: enUS,
|
||||
};
|
||||
|
||||
export type LocaleKey = keyof typeof locales;
|
||||
|
|
@ -16,30 +16,30 @@ export type LocaleKey = keyof typeof locales;
|
|||
* Format a date string to a readable format
|
||||
*/
|
||||
export function formatDate(
|
||||
date: string | Date,
|
||||
formatStr: string = 'PPP',
|
||||
locale: LocaleKey = 'de'
|
||||
date: string | Date,
|
||||
formatStr: string = 'PPP',
|
||||
locale: LocaleKey = 'de'
|
||||
): string {
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
return format(dateObj, formatStr, { locale: locales[locale] });
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
return format(dateObj, formatStr, { locale: locales[locale] });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relative time from now (e.g., "2 hours ago")
|
||||
*/
|
||||
export function formatRelativeTime(date: string | Date, locale: LocaleKey = 'de'): string {
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
return formatDistanceToNow(dateObj, {
|
||||
addSuffix: true,
|
||||
locale: locales[locale],
|
||||
});
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
return formatDistanceToNow(dateObj, {
|
||||
addSuffix: true,
|
||||
locale: locales[locale],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a date for API requests (ISO string)
|
||||
*/
|
||||
export function toISOString(date: Date): string {
|
||||
return date.toISOString();
|
||||
return date.toISOString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -50,28 +50,25 @@ export function toISOString(date: Date): string {
|
|||
* - Yesterday → "Yesterday, 14:30" / "Gestern, 14:30"
|
||||
* - Other → "15. März 2024, 14:30" / "March 15, 2024, 2:30 PM"
|
||||
*/
|
||||
export function formatTimestamp(
|
||||
date: string | Date,
|
||||
locale: LocaleKey = 'de'
|
||||
): string {
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
const timeFormat = locale === 'de' ? 'HH:mm' : 'h:mm a';
|
||||
export function formatTimestamp(date: string | Date, locale: LocaleKey = 'de'): string {
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
const timeFormat = locale === 'de' ? 'HH:mm' : 'h:mm a';
|
||||
|
||||
const labels = {
|
||||
de: { today: 'Heute', yesterday: 'Gestern' },
|
||||
en: { today: 'Today', yesterday: 'Yesterday' },
|
||||
};
|
||||
const labels = {
|
||||
de: { today: 'Heute', yesterday: 'Gestern' },
|
||||
en: { today: 'Today', yesterday: 'Yesterday' },
|
||||
};
|
||||
|
||||
if (isToday(dateObj)) {
|
||||
return `${labels[locale].today}, ${format(dateObj, timeFormat)}`;
|
||||
}
|
||||
if (isToday(dateObj)) {
|
||||
return `${labels[locale].today}, ${format(dateObj, timeFormat)}`;
|
||||
}
|
||||
|
||||
if (isYesterday(dateObj)) {
|
||||
return `${labels[locale].yesterday}, ${format(dateObj, timeFormat)}`;
|
||||
}
|
||||
if (isYesterday(dateObj)) {
|
||||
return `${labels[locale].yesterday}, ${format(dateObj, timeFormat)}`;
|
||||
}
|
||||
|
||||
const dateFormat = locale === 'de' ? 'd. MMMM yyyy' : 'MMMM d, yyyy';
|
||||
return `${format(dateObj, dateFormat, { locale: locales[locale] })}, ${format(dateObj, timeFormat)}`;
|
||||
const dateFormat = locale === 'de' ? 'd. MMMM yyyy' : 'MMMM d, yyyy';
|
||||
return `${format(dateObj, dateFormat, { locale: locales[locale] })}, ${format(dateObj, timeFormat)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,7 +84,7 @@ export { isToday, isYesterday } from 'date-fns';
|
|||
* @returns Formatted short date string (e.g., "15 Mar 2024" or "15. Mär. 2024")
|
||||
*/
|
||||
export function formatShortDate(date: Date | string, locale: LocaleKey = 'de'): string {
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
|
||||
return format(dateObj, 'dd MMM yyyy', { locale: locales[locale] });
|
||||
return format(dateObj, 'dd MMM yyyy', { locale: locales[locale] });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue