mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 21:19:40 +02:00
feat: add monorepo configuration and shared packages structure
Root-level setup: - package.json with Turborepo scripts - pnpm-workspace.yaml for workspace management - turbo.json for build pipeline - Common config files (.nvmrc, .prettierrc, .editorconfig) Shared packages (packages/): - @manacore/shared-types - Common TypeScript types - @manacore/shared-supabase - Unified Supabase client - @manacore/shared-utils - Date, string, async utilities - @manacore/shared-ui - React Native UI components (placeholder) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e7f5f942f3
commit
2c58d03f63
23 changed files with 738 additions and 0 deletions
43
packages/shared-utils/src/date.ts
Normal file
43
packages/shared-utils/src/date.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* Date utility functions
|
||||
*/
|
||||
|
||||
import { format, formatDistanceToNow, parseISO } from 'date-fns';
|
||||
import { de, enUS } from 'date-fns/locale';
|
||||
|
||||
const locales = {
|
||||
de,
|
||||
en: enUS,
|
||||
};
|
||||
|
||||
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'
|
||||
): string {
|
||||
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],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a date for API requests (ISO string)
|
||||
*/
|
||||
export function toISOString(date: Date): string {
|
||||
return date.toISOString();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue