@mrck-labs/vanaheim-shared 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -110,7 +110,7 @@ interface NewFocusCategory {
110
110
  sortOrder?: number;
111
111
  isDefault?: boolean;
112
112
  }
113
- type FocusSessionStatus = 'active' | 'completed' | 'abandoned';
113
+ type FocusSessionStatus = "active" | "completed" | "abandoned";
114
114
  interface FocusSession {
115
115
  id: string;
116
116
  userId: string;
@@ -140,7 +140,7 @@ interface FocusSessionFilters {
140
140
  startedAfter?: string;
141
141
  startedBefore?: string;
142
142
  }
143
- type ChatMessageRole = 'user' | 'assistant' | 'system';
143
+ type ChatMessageRole = "user" | "assistant" | "system";
144
144
  interface ChatConversation {
145
145
  id: string;
146
146
  userId: string;
@@ -181,7 +181,7 @@ interface NewEFLink {
181
181
  icon?: string | null;
182
182
  sortOrder?: number;
183
183
  }
184
- type LieuDayType = 'earned' | 'used';
184
+ type LieuDayType = "earned" | "used";
185
185
  interface LieuDay {
186
186
  id: string;
187
187
  userId: string;
@@ -196,8 +196,8 @@ interface NewLieuDay {
196
196
  date: string;
197
197
  reason?: string | null;
198
198
  }
199
- type BankConnectionStatus = 'pending' | 'linked' | 'expired' | 'error';
200
- type TransactionType = 'debit' | 'credit';
199
+ type BankConnectionStatus = "pending" | "linked" | "expired" | "error";
200
+ type TransactionType = "debit" | "credit";
201
201
  interface BankConnection {
202
202
  id: string;
203
203
  userId: string;
@@ -224,6 +224,90 @@ interface BankTransaction {
224
224
  transactionType: TransactionType | null;
225
225
  createdAt: string;
226
226
  }
227
+ interface HealthCategory {
228
+ id: string;
229
+ userId: string;
230
+ name: string;
231
+ icon: string;
232
+ color: string;
233
+ sortOrder: number;
234
+ isDefault: boolean;
235
+ createdAt: string;
236
+ updatedAt: string;
237
+ }
238
+ interface NewHealthCategory {
239
+ name: string;
240
+ icon: string;
241
+ color: string;
242
+ sortOrder?: number;
243
+ isDefault?: boolean;
244
+ }
245
+ type HealthFrequencyType = "daily" | "specific_days" | "times_per_week" | "times_per_month";
246
+ interface HealthFrequencyConfig {
247
+ days?: number[];
248
+ target?: number;
249
+ }
250
+ interface HealthHabit {
251
+ id: string;
252
+ userId: string;
253
+ categoryId: string;
254
+ name: string;
255
+ description: string | null;
256
+ frequencyType: HealthFrequencyType;
257
+ frequencyConfig: string | null;
258
+ targetAmount: number | null;
259
+ targetUnit: string | null;
260
+ streakCurrent: number;
261
+ streakBest: number;
262
+ isActive: boolean;
263
+ createdAt: string;
264
+ updatedAt: string;
265
+ category?: HealthCategory;
266
+ }
267
+ interface NewHealthHabit {
268
+ categoryId: string;
269
+ name: string;
270
+ description?: string | null;
271
+ frequencyType: HealthFrequencyType;
272
+ frequencyConfig?: HealthFrequencyConfig | null;
273
+ targetAmount?: number | null;
274
+ targetUnit?: string | null;
275
+ isActive?: boolean;
276
+ }
277
+ interface HealthCompletion {
278
+ id: string;
279
+ habitId: string;
280
+ userId: string;
281
+ date: string;
282
+ completedAt: string;
283
+ notes: string | null;
284
+ }
285
+ interface NewHealthCompletion {
286
+ habitId: string;
287
+ date?: string;
288
+ notes?: string | null;
289
+ }
290
+ interface HealthHabitFilters {
291
+ categoryId?: string;
292
+ isActive?: boolean;
293
+ frequencyType?: HealthFrequencyType;
294
+ }
295
+ interface HealthCompletionFilters {
296
+ habitId?: string;
297
+ dateFrom?: string;
298
+ dateTo?: string;
299
+ }
300
+ interface HealthStats {
301
+ totalHabits: number;
302
+ dailyHabits: number;
303
+ weeklyHabits: number;
304
+ completedToday: number;
305
+ pendingToday: number;
306
+ completionRate: number;
307
+ totalStreak: number;
308
+ bestStreak: number;
309
+ weeklyCompletions: number;
310
+ }
227
311
  interface Setting {
228
312
  id: string;
229
313
  userId: string;
@@ -237,4 +321,4 @@ interface ExchangeRate {
237
321
  updatedAt: string;
238
322
  }
239
323
 
240
- export type { BankConnectionStatus as B, ChatMessageRole as C, ExpenseCategory as E, FocusCategory as F, IncomeCategory as I, LieuDayType as L, NewExpenseCategory as N, Setting as S, TransactionType as T, Expense as a, NewExpense as b, NewIncomeCategory as c, Income as d, NewIncome as e, NewFocusCategory as f, FocusSessionStatus as g, FocusSession as h, NewFocusSession as i, FocusSessionFilters as j, ChatConversation as k, NewChatConversation as l, ChatMessage as m, NewChatMessage as n, EFLink as o, NewEFLink as p, LieuDay as q, NewLieuDay as r, BankConnection as s, BankTransaction as t, ExchangeRate as u };
324
+ export type { NewHealthCompletion as A, BankConnectionStatus as B, ChatMessageRole as C, HealthHabitFilters as D, ExpenseCategory as E, FocusCategory as F, HealthCompletionFilters as G, HealthCategory as H, IncomeCategory as I, HealthStats as J, ExchangeRate as K, LieuDayType as L, NewExpenseCategory as N, Setting as S, TransactionType as T, Expense as a, NewExpense as b, NewIncomeCategory as c, Income as d, NewIncome as e, NewFocusCategory as f, FocusSessionStatus as g, FocusSession as h, NewFocusSession as i, FocusSessionFilters as j, ChatConversation as k, NewChatConversation as l, ChatMessage as m, NewChatMessage as n, EFLink as o, NewEFLink as p, LieuDay as q, NewLieuDay as r, BankConnection as s, BankTransaction as t, NewHealthCategory as u, HealthFrequencyType as v, HealthFrequencyConfig as w, HealthHabit as x, NewHealthHabit as y, HealthCompletion as z };
@@ -110,7 +110,7 @@ interface NewFocusCategory {
110
110
  sortOrder?: number;
111
111
  isDefault?: boolean;
112
112
  }
113
- type FocusSessionStatus = 'active' | 'completed' | 'abandoned';
113
+ type FocusSessionStatus = "active" | "completed" | "abandoned";
114
114
  interface FocusSession {
115
115
  id: string;
116
116
  userId: string;
@@ -140,7 +140,7 @@ interface FocusSessionFilters {
140
140
  startedAfter?: string;
141
141
  startedBefore?: string;
142
142
  }
143
- type ChatMessageRole = 'user' | 'assistant' | 'system';
143
+ type ChatMessageRole = "user" | "assistant" | "system";
144
144
  interface ChatConversation {
145
145
  id: string;
146
146
  userId: string;
@@ -181,7 +181,7 @@ interface NewEFLink {
181
181
  icon?: string | null;
182
182
  sortOrder?: number;
183
183
  }
184
- type LieuDayType = 'earned' | 'used';
184
+ type LieuDayType = "earned" | "used";
185
185
  interface LieuDay {
186
186
  id: string;
187
187
  userId: string;
@@ -196,8 +196,8 @@ interface NewLieuDay {
196
196
  date: string;
197
197
  reason?: string | null;
198
198
  }
199
- type BankConnectionStatus = 'pending' | 'linked' | 'expired' | 'error';
200
- type TransactionType = 'debit' | 'credit';
199
+ type BankConnectionStatus = "pending" | "linked" | "expired" | "error";
200
+ type TransactionType = "debit" | "credit";
201
201
  interface BankConnection {
202
202
  id: string;
203
203
  userId: string;
@@ -224,6 +224,90 @@ interface BankTransaction {
224
224
  transactionType: TransactionType | null;
225
225
  createdAt: string;
226
226
  }
227
+ interface HealthCategory {
228
+ id: string;
229
+ userId: string;
230
+ name: string;
231
+ icon: string;
232
+ color: string;
233
+ sortOrder: number;
234
+ isDefault: boolean;
235
+ createdAt: string;
236
+ updatedAt: string;
237
+ }
238
+ interface NewHealthCategory {
239
+ name: string;
240
+ icon: string;
241
+ color: string;
242
+ sortOrder?: number;
243
+ isDefault?: boolean;
244
+ }
245
+ type HealthFrequencyType = "daily" | "specific_days" | "times_per_week" | "times_per_month";
246
+ interface HealthFrequencyConfig {
247
+ days?: number[];
248
+ target?: number;
249
+ }
250
+ interface HealthHabit {
251
+ id: string;
252
+ userId: string;
253
+ categoryId: string;
254
+ name: string;
255
+ description: string | null;
256
+ frequencyType: HealthFrequencyType;
257
+ frequencyConfig: string | null;
258
+ targetAmount: number | null;
259
+ targetUnit: string | null;
260
+ streakCurrent: number;
261
+ streakBest: number;
262
+ isActive: boolean;
263
+ createdAt: string;
264
+ updatedAt: string;
265
+ category?: HealthCategory;
266
+ }
267
+ interface NewHealthHabit {
268
+ categoryId: string;
269
+ name: string;
270
+ description?: string | null;
271
+ frequencyType: HealthFrequencyType;
272
+ frequencyConfig?: HealthFrequencyConfig | null;
273
+ targetAmount?: number | null;
274
+ targetUnit?: string | null;
275
+ isActive?: boolean;
276
+ }
277
+ interface HealthCompletion {
278
+ id: string;
279
+ habitId: string;
280
+ userId: string;
281
+ date: string;
282
+ completedAt: string;
283
+ notes: string | null;
284
+ }
285
+ interface NewHealthCompletion {
286
+ habitId: string;
287
+ date?: string;
288
+ notes?: string | null;
289
+ }
290
+ interface HealthHabitFilters {
291
+ categoryId?: string;
292
+ isActive?: boolean;
293
+ frequencyType?: HealthFrequencyType;
294
+ }
295
+ interface HealthCompletionFilters {
296
+ habitId?: string;
297
+ dateFrom?: string;
298
+ dateTo?: string;
299
+ }
300
+ interface HealthStats {
301
+ totalHabits: number;
302
+ dailyHabits: number;
303
+ weeklyHabits: number;
304
+ completedToday: number;
305
+ pendingToday: number;
306
+ completionRate: number;
307
+ totalStreak: number;
308
+ bestStreak: number;
309
+ weeklyCompletions: number;
310
+ }
227
311
  interface Setting {
228
312
  id: string;
229
313
  userId: string;
@@ -237,4 +321,4 @@ interface ExchangeRate {
237
321
  updatedAt: string;
238
322
  }
239
323
 
240
- export type { BankConnectionStatus as B, ChatMessageRole as C, ExpenseCategory as E, FocusCategory as F, IncomeCategory as I, LieuDayType as L, NewExpenseCategory as N, Setting as S, TransactionType as T, Expense as a, NewExpense as b, NewIncomeCategory as c, Income as d, NewIncome as e, NewFocusCategory as f, FocusSessionStatus as g, FocusSession as h, NewFocusSession as i, FocusSessionFilters as j, ChatConversation as k, NewChatConversation as l, ChatMessage as m, NewChatMessage as n, EFLink as o, NewEFLink as p, LieuDay as q, NewLieuDay as r, BankConnection as s, BankTransaction as t, ExchangeRate as u };
324
+ export type { NewHealthCompletion as A, BankConnectionStatus as B, ChatMessageRole as C, HealthHabitFilters as D, ExpenseCategory as E, FocusCategory as F, HealthCompletionFilters as G, HealthCategory as H, IncomeCategory as I, HealthStats as J, ExchangeRate as K, LieuDayType as L, NewExpenseCategory as N, Setting as S, TransactionType as T, Expense as a, NewExpense as b, NewIncomeCategory as c, Income as d, NewIncome as e, NewFocusCategory as f, FocusSessionStatus as g, FocusSession as h, NewFocusSession as i, FocusSessionFilters as j, ChatConversation as k, NewChatConversation as l, ChatMessage as m, NewChatMessage as n, EFLink as o, NewEFLink as p, LieuDay as q, NewLieuDay as r, BankConnection as s, BankTransaction as t, NewHealthCategory as u, HealthFrequencyType as v, HealthFrequencyConfig as w, HealthHabit as x, NewHealthHabit as y, HealthCompletion as z };
@@ -123,6 +123,10 @@ declare function formatDateLong(dateStr: string): string;
123
123
  declare function formatMonthYear(date: Date): string;
124
124
  /**
125
125
  * Format a date/time to HH:MM format
126
+ * Use this for formatting Date objects or ISO strings to time display
127
+ * @example formatTimeHHMM(new Date()) => "14:30"
128
+ *
129
+ * Note: For formatting seconds (e.g., timer display), use formatTime from utils
126
130
  */
127
131
  declare function formatTimeHHMM(date: Date | string): string;
128
132
  /**
@@ -123,6 +123,10 @@ declare function formatDateLong(dateStr: string): string;
123
123
  declare function formatMonthYear(date: Date): string;
124
124
  /**
125
125
  * Format a date/time to HH:MM format
126
+ * Use this for formatting Date objects or ISO strings to time display
127
+ * @example formatTimeHHMM(new Date()) => "14:30"
128
+ *
129
+ * Note: For formatting seconds (e.g., timer display), use formatTime from utils
126
130
  */
127
131
  declare function formatTimeHHMM(date: Date | string): string;
128
132
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/date/index.ts"],"sourcesContent":["/**\n * Date Utilities\n *\n * Pure functions for date manipulation and formatting.\n * Works in both Node.js and browser/React Native environments.\n *\n * @example\n * import { getTodayString, addDays, formatRelativeTime } from '@mrck-labs/vanaheim-shared/date'\n *\n * const today = getTodayString() // \"2024-12-16\"\n * const nextWeek = addDays(today, 7) // \"2024-12-23\"\n */\n\n// ============================================================================\n// Core Utilities\n// ============================================================================\n\n/**\n * Normalize a date to midnight (00:00:00.000)\n */\nexport function normalizeToMidnight(date: Date): Date {\n const d = new Date(date)\n d.setHours(0, 0, 0, 0)\n return d\n}\n\n/**\n * Get today's date normalized to midnight\n */\nexport function getTodayMidnight(): Date {\n return normalizeToMidnight(new Date())\n}\n\n/**\n * Format a Date object to YYYY-MM-DD string\n * @example formatDateString(new Date()) => \"2024-12-16\"\n */\nexport function formatDateString(date: Date): string {\n return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`\n}\n\n/**\n * Get today's local date string (YYYY-MM-DD)\n */\nexport function getTodayString(): string {\n return formatDateString(new Date())\n}\n\n/**\n * Parse a YYYY-MM-DD string to a local Date object\n * Avoids timezone issues by appending T00:00:00\n */\nexport function parseLocalDate(dateStr: string): Date {\n return new Date(dateStr + 'T00:00:00')\n}\n\n// ============================================================================\n// Date Checks\n// ============================================================================\n\n/**\n * Check if a date string is today\n */\nexport function isToday(dateStr: string | null): boolean {\n if (!dateStr) return false\n return dateStr === getTodayString()\n}\n\n/**\n * Check if a date string is in the past (before today)\n */\nexport function isOverdue(dateStr: string | null): boolean {\n if (!dateStr) return false\n return dateStr < getTodayString()\n}\n\n/**\n * Check if a date is due within a threshold of days\n * @param dateStr - Date in YYYY-MM-DD format\n * @param daysThreshold - Number of days to check (default: 7)\n */\nexport function isDueSoon(dateStr: string | null, daysThreshold: number = 7): boolean {\n if (!dateStr) return false\n if (isOverdue(dateStr)) return false\n\n const today = getTodayMidnight()\n const targetDate = parseLocalDate(dateStr)\n const diffMs = targetDate.getTime() - today.getTime()\n const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))\n\n return diffDays >= 0 && diffDays <= daysThreshold\n}\n\n// ============================================================================\n// Date Arithmetic\n// ============================================================================\n\n/**\n * Add days to a date string\n * @param dateStr - Date in YYYY-MM-DD format\n * @param days - Number of days to add (can be negative)\n * @returns New date string in YYYY-MM-DD format\n */\nexport function addDays(dateStr: string, days: number): string {\n const date = parseLocalDate(dateStr)\n date.setDate(date.getDate() + days)\n return formatDateString(date)\n}\n\n/**\n * Subtract days from a date string\n */\nexport function subtractDays(dateStr: string, days: number): string {\n return addDays(dateStr, -days)\n}\n\n/**\n * Get yesterday's date string (YYYY-MM-DD)\n */\nexport function getYesterdayString(): string {\n return subtractDays(getTodayString(), 1)\n}\n\n/**\n * Get tomorrow's date string (YYYY-MM-DD)\n */\nexport function getTomorrowString(): string {\n return addDays(getTodayString(), 1)\n}\n\n// ============================================================================\n// ISO String Helpers (for database queries)\n// ============================================================================\n\n/**\n * Get start of day as ISO string\n * @param dateStr - Date in YYYY-MM-DD format\n * @returns ISO string like \"2024-12-15T00:00:00.000Z\"\n */\nexport function getStartOfDayISO(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return new Date(date.getFullYear(), date.getMonth(), date.getDate()).toISOString()\n}\n\n/**\n * Get end of day as ISO string\n * @param dateStr - Date in YYYY-MM-DD format\n * @returns ISO string like \"2024-12-15T23:59:59.999Z\"\n */\nexport function getEndOfDayISO(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return new Date(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n 23,\n 59,\n 59,\n 999\n ).toISOString()\n}\n\n// ============================================================================\n// Week Utilities\n// ============================================================================\n\n/**\n * Get the start of the week (Monday) for a given date\n */\nexport function getWeekStart(date: Date): Date {\n const d = new Date(date)\n const day = d.getDay()\n const diff = d.getDate() - day + (day === 0 ? -6 : 1) // Monday\n d.setDate(diff)\n d.setHours(0, 0, 0, 0)\n return d\n}\n\n/**\n * Get the end of the week (Sunday) for a given week start\n */\nexport function getWeekEnd(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() + 6)\n return d\n}\n\n/**\n * Get the start of the previous week\n */\nexport function getPreviousWeek(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() - 7)\n return d\n}\n\n/**\n * Get the start of the next week\n */\nexport function getNextWeek(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() + 7)\n return d\n}\n\n/**\n * Get start of week (Monday) as date string\n */\nexport function getWeekStartString(baseDate: Date = new Date()): string {\n return formatDateString(getWeekStart(baseDate))\n}\n\n/**\n * Get end of week (Sunday) as date string\n */\nexport function getWeekEndString(baseDate: Date = new Date()): string {\n return formatDateString(getWeekEnd(getWeekStart(baseDate)))\n}\n\n/**\n * Format a week range for display\n * @example \"Dec 2 - 8, 2024\" or \"Nov 25 - Dec 1, 2024\"\n */\nexport function formatWeekRange(weekStart: Date): string {\n const weekEnd = getWeekEnd(weekStart)\n const startMonth = weekStart.toLocaleDateString('en-US', { month: 'short' })\n const endMonth = weekEnd.toLocaleDateString('en-US', { month: 'short' })\n\n if (startMonth === endMonth) {\n return `${startMonth} ${weekStart.getDate()} - ${weekEnd.getDate()}, ${weekStart.getFullYear()}`\n }\n\n return `${startMonth} ${weekStart.getDate()} - ${endMonth} ${weekEnd.getDate()}, ${weekStart.getFullYear()}`\n}\n\n// ============================================================================\n// Display Formatting\n// ============================================================================\n\n/**\n * Format a date string for display with full weekday\n * @example \"Monday, December 15, 2024\"\n */\nexport function formatFullDate(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-US', {\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n })\n}\n\n/**\n * Format date for display in long form\n * @example \"Monday, 9 December\"\n */\nexport function formatDateLong(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-GB', {\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n })\n}\n\n/**\n * Format month and year\n * @example \"December 2024\"\n */\nexport function formatMonthYear(date: Date): string {\n return date.toLocaleDateString('en-US', {\n month: 'long',\n year: 'numeric',\n })\n}\n\n/**\n * Format a date/time to HH:MM format\n */\nexport function formatTimeHHMM(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })\n}\n\n/**\n * Format a date/time to HH:MM:SS format\n */\nexport function formatTimeWithSeconds(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })\n}\n\n// ============================================================================\n// Contextual Formatting\n// ============================================================================\n\n/**\n * Format a date string for display as a header\n * Returns \"Overdue\", \"Today\", \"Tomorrow\", or formatted date\n */\nexport function formatDateHeader(dateStr: string): string {\n const today = getTodayString()\n\n if (dateStr < today) {\n return 'Overdue'\n }\n\n if (dateStr === today) {\n return 'Today'\n }\n\n const tomorrowStr = getTomorrowString()\n if (dateStr === tomorrowStr) {\n return 'Tomorrow'\n }\n\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'short',\n day: 'numeric',\n })\n}\n\n/**\n * Format a due date for display in task items (simple string version)\n * Returns \"Overdue\", \"Today\", \"Tomorrow\", or formatted date\n *\n * Note: For version that returns { text, isOverdue }, use formatDueDate from utils/formatters\n */\nexport function formatDueDateString(dateStr: string | null): string {\n if (!dateStr) return 'No due date'\n\n const today = getTodayString()\n const tomorrowStr = getTomorrowString()\n\n if (dateStr < today) {\n const date = parseLocalDate(dateStr)\n return `Overdue • ${date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })}`\n }\n\n if (dateStr === today) {\n return 'Today'\n }\n\n if (dateStr === tomorrowStr) {\n return 'Tomorrow'\n }\n\n const date = parseLocalDate(dateStr)\n const currentYear = new Date().getFullYear()\n const dateYear = date.getFullYear()\n\n return date.toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: dateYear !== currentYear ? 'numeric' : undefined,\n })\n}\n\n/**\n * Format a date/time as relative time string (extended version)\n * Accepts both Date objects and ISO strings\n * @example \"Just now\", \"5m ago\", \"2h ago\", \"3d ago\"\n *\n * Note: For simple string input, you can also use formatRelativeTime from utils/formatters\n */\nexport function formatRelativeTimeExtended(dateStr: string | Date): string {\n const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr\n const now = new Date()\n const diffMs = now.getTime() - date.getTime()\n const diffMins = Math.floor(diffMs / 60000)\n const diffHours = Math.floor(diffMins / 60)\n const diffDays = Math.floor(diffHours / 24)\n\n if (diffMins < 1) return 'Just now'\n if (diffMins < 60) return `${diffMins}m ago`\n if (diffHours < 24) return `${diffHours}h ago`\n if (diffDays < 7) return `${diffDays}d ago`\n return date.toLocaleDateString()\n}\n\n/**\n * Format a due date relative to today with contextual prefix\n * @example \"Due today\", \"Due tomorrow\", \"Due in 3 days\", \"2 days overdue\"\n */\nexport function formatRelativeDueDate(\n dateStr: string,\n options?: {\n duePrefix?: string\n overduePrefix?: string\n }\n): string {\n const { duePrefix = 'Due', overduePrefix = '' } = options || {}\n const date = parseLocalDate(dateStr)\n const now = normalizeToMidnight(new Date())\n\n const diffMs = date.getTime() - now.getTime()\n const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24))\n\n if (diffDays < 0) {\n const absDays = Math.abs(diffDays)\n return overduePrefix\n ? `${overduePrefix} ${absDays} day${absDays !== 1 ? 's' : ''} overdue`\n : `${absDays} day${absDays !== 1 ? 's' : ''} overdue`\n }\n if (diffDays === 0) return `${duePrefix} today`\n if (diffDays === 1) return `${duePrefix} tomorrow`\n if (diffDays <= 7) return `${duePrefix} in ${diffDays} days`\n\n return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })\n}\n\n/**\n * Format a pay/income date relative to today\n * @example \"Today\", \"Tomorrow\", \"In 3 days\", \"2 days ago\"\n */\nexport function formatRelativePayDate(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n const now = normalizeToMidnight(new Date())\n\n const diffMs = date.getTime() - now.getTime()\n const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24))\n\n if (diffDays < 0) {\n const absDays = Math.abs(diffDays)\n return `${absDays} day${absDays !== 1 ? 's' : ''} ago`\n }\n if (diffDays === 0) return 'Today'\n if (diffDays === 1) return 'Tomorrow'\n if (diffDays <= 7) return `In ${diffDays} days`\n\n return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })\n}\n\n// ============================================================================\n// Localized Formatting\n// ============================================================================\n\nexport type DateFormat = 'short' | 'medium' | 'long' | 'weekday'\nexport type TimeFormat = 'short' | 'withSeconds'\n\n/**\n * Format a date with various preset formats\n */\nexport function formatDateLocalized(date: Date | string, format: DateFormat = 'medium'): string {\n const d = typeof date === 'string' ? new Date(date) : date\n\n switch (format) {\n case 'short':\n return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })\n case 'medium':\n return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n case 'long':\n return d.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n })\n case 'weekday':\n return d.toLocaleDateString('en-US', { weekday: 'short' })\n default:\n return d.toLocaleDateString()\n }\n}\n\n/**\n * Format a time with various preset formats\n */\nexport function formatTimeLocalized(date: Date | string, format: TimeFormat = 'short'): string {\n const d = typeof date === 'string' ? new Date(date) : date\n\n switch (format) {\n case 'short':\n return d.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true })\n case 'withSeconds':\n return d.toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n })\n default:\n return d.toLocaleTimeString()\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,oBAAoB,MAAkB;AACpD,QAAM,IAAI,IAAI,KAAK,IAAI;AACvB,IAAE,SAAS,GAAG,GAAG,GAAG,CAAC;AACrB,SAAO;AACT;AAKO,SAAS,mBAAyB;AACvC,SAAO,oBAAoB,oBAAI,KAAK,CAAC;AACvC;AAMO,SAAS,iBAAiB,MAAoB;AACnD,SAAO,GAAG,KAAK,YAAY,CAAC,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,IAA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AAqB,UAAkB;AAC9F,QAAM,IAAI,OAAO,SAAS,WAAW,IAAI,KAAK,IAAI,IAAI;AAEtD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,EAAE,mBAAmB,SAAS,EAAE,OAAO,SAAS,KAAK,UAAU,CAAC;AAAA,IACzE,KAAK;AACH,aAAO,EAAE,mBAAmB,SAAS,EAAE,OAAO,SAAS,KAAK,WAAW,MAAM,UAAU,CAAC;AAAA,IAC1F,KAAK;AACH,aAAO,EAAE,mBAAmB,SAAS;AAAA,QACnC,SAAS;AAAA,QACT,OAAO;AAAA,QACP,KAAK;AAAA,QACL,MAAM;AAAA,MACR,CAAC;AAAA,IACH,KAAK;AACH,aAAO,EAAE,mBAAmB,SAAS,EAAE,SAAS,QAAQ,CAAC;AAAA,IAC3D;AACE,aAAO,EAAE,mBAAmB;AAAA,EAChC;AACF;AAKO,SAAS,oBAAoB,MAAqB,SAAqB,SAAiB;AAC7F,QAAM,IAAI,OAAO,SAAS,WAAW,IAAI,KAAK,IAAI,IAAI;AAEtD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,EAAE,mBAAmB,SAAS,EAAE,MAAM,WAAW,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAAA,IAC3F,KAAK;AACH,aAAO,EAAE,mBAAmB,SAAS;AAAA,QACnC,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AACE,aAAO,EAAE,mBAAmB;AAAA,EAChC;AACF;","names":["date"]}
1
+ {"version":3,"sources":["../../src/date/index.ts"],"sourcesContent":["/**\n * Date Utilities\n *\n * Pure functions for date manipulation and formatting.\n * Works in both Node.js and browser/React Native environments.\n *\n * @example\n * import { getTodayString, addDays, formatRelativeTime } from '@mrck-labs/vanaheim-shared/date'\n *\n * const today = getTodayString() // \"2024-12-16\"\n * const nextWeek = addDays(today, 7) // \"2024-12-23\"\n */\n\n// ============================================================================\n// Core Utilities\n// ============================================================================\n\n/**\n * Normalize a date to midnight (00:00:00.000)\n */\nexport function normalizeToMidnight(date: Date): Date {\n const d = new Date(date)\n d.setHours(0, 0, 0, 0)\n return d\n}\n\n/**\n * Get today's date normalized to midnight\n */\nexport function getTodayMidnight(): Date {\n return normalizeToMidnight(new Date())\n}\n\n/**\n * Format a Date object to YYYY-MM-DD string\n * @example formatDateString(new Date()) => \"2024-12-16\"\n */\nexport function formatDateString(date: Date): string {\n return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`\n}\n\n/**\n * Get today's local date string (YYYY-MM-DD)\n */\nexport function getTodayString(): string {\n return formatDateString(new Date())\n}\n\n/**\n * Parse a YYYY-MM-DD string to a local Date object\n * Avoids timezone issues by appending T00:00:00\n */\nexport function parseLocalDate(dateStr: string): Date {\n return new Date(dateStr + 'T00:00:00')\n}\n\n// ============================================================================\n// Date Checks\n// ============================================================================\n\n/**\n * Check if a date string is today\n */\nexport function isToday(dateStr: string | null): boolean {\n if (!dateStr) return false\n return dateStr === getTodayString()\n}\n\n/**\n * Check if a date string is in the past (before today)\n */\nexport function isOverdue(dateStr: string | null): boolean {\n if (!dateStr) return false\n return dateStr < getTodayString()\n}\n\n/**\n * Check if a date is due within a threshold of days\n * @param dateStr - Date in YYYY-MM-DD format\n * @param daysThreshold - Number of days to check (default: 7)\n */\nexport function isDueSoon(dateStr: string | null, daysThreshold: number = 7): boolean {\n if (!dateStr) return false\n if (isOverdue(dateStr)) return false\n\n const today = getTodayMidnight()\n const targetDate = parseLocalDate(dateStr)\n const diffMs = targetDate.getTime() - today.getTime()\n const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))\n\n return diffDays >= 0 && diffDays <= daysThreshold\n}\n\n// ============================================================================\n// Date Arithmetic\n// ============================================================================\n\n/**\n * Add days to a date string\n * @param dateStr - Date in YYYY-MM-DD format\n * @param days - Number of days to add (can be negative)\n * @returns New date string in YYYY-MM-DD format\n */\nexport function addDays(dateStr: string, days: number): string {\n const date = parseLocalDate(dateStr)\n date.setDate(date.getDate() + days)\n return formatDateString(date)\n}\n\n/**\n * Subtract days from a date string\n */\nexport function subtractDays(dateStr: string, days: number): string {\n return addDays(dateStr, -days)\n}\n\n/**\n * Get yesterday's date string (YYYY-MM-DD)\n */\nexport function getYesterdayString(): string {\n return subtractDays(getTodayString(), 1)\n}\n\n/**\n * Get tomorrow's date string (YYYY-MM-DD)\n */\nexport function getTomorrowString(): string {\n return addDays(getTodayString(), 1)\n}\n\n// ============================================================================\n// ISO String Helpers (for database queries)\n// ============================================================================\n\n/**\n * Get start of day as ISO string\n * @param dateStr - Date in YYYY-MM-DD format\n * @returns ISO string like \"2024-12-15T00:00:00.000Z\"\n */\nexport function getStartOfDayISO(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return new Date(date.getFullYear(), date.getMonth(), date.getDate()).toISOString()\n}\n\n/**\n * Get end of day as ISO string\n * @param dateStr - Date in YYYY-MM-DD format\n * @returns ISO string like \"2024-12-15T23:59:59.999Z\"\n */\nexport function getEndOfDayISO(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return new Date(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n 23,\n 59,\n 59,\n 999\n ).toISOString()\n}\n\n// ============================================================================\n// Week Utilities\n// ============================================================================\n\n/**\n * Get the start of the week (Monday) for a given date\n */\nexport function getWeekStart(date: Date): Date {\n const d = new Date(date)\n const day = d.getDay()\n const diff = d.getDate() - day + (day === 0 ? -6 : 1) // Monday\n d.setDate(diff)\n d.setHours(0, 0, 0, 0)\n return d\n}\n\n/**\n * Get the end of the week (Sunday) for a given week start\n */\nexport function getWeekEnd(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() + 6)\n return d\n}\n\n/**\n * Get the start of the previous week\n */\nexport function getPreviousWeek(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() - 7)\n return d\n}\n\n/**\n * Get the start of the next week\n */\nexport function getNextWeek(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() + 7)\n return d\n}\n\n/**\n * Get start of week (Monday) as date string\n */\nexport function getWeekStartString(baseDate: Date = new Date()): string {\n return formatDateString(getWeekStart(baseDate))\n}\n\n/**\n * Get end of week (Sunday) as date string\n */\nexport function getWeekEndString(baseDate: Date = new Date()): string {\n return formatDateString(getWeekEnd(getWeekStart(baseDate)))\n}\n\n/**\n * Format a week range for display\n * @example \"Dec 2 - 8, 2024\" or \"Nov 25 - Dec 1, 2024\"\n */\nexport function formatWeekRange(weekStart: Date): string {\n const weekEnd = getWeekEnd(weekStart)\n const startMonth = weekStart.toLocaleDateString('en-US', { month: 'short' })\n const endMonth = weekEnd.toLocaleDateString('en-US', { month: 'short' })\n\n if (startMonth === endMonth) {\n return `${startMonth} ${weekStart.getDate()} - ${weekEnd.getDate()}, ${weekStart.getFullYear()}`\n }\n\n return `${startMonth} ${weekStart.getDate()} - ${endMonth} ${weekEnd.getDate()}, ${weekStart.getFullYear()}`\n}\n\n// ============================================================================\n// Display Formatting\n// ============================================================================\n\n/**\n * Format a date string for display with full weekday\n * @example \"Monday, December 15, 2024\"\n */\nexport function formatFullDate(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-US', {\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n })\n}\n\n/**\n * Format date for display in long form\n * @example \"Monday, 9 December\"\n */\nexport function formatDateLong(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-GB', {\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n })\n}\n\n/**\n * Format month and year\n * @example \"December 2024\"\n */\nexport function formatMonthYear(date: Date): string {\n return date.toLocaleDateString('en-US', {\n month: 'long',\n year: 'numeric',\n })\n}\n\n/**\n * Format a date/time to HH:MM format\n * Use this for formatting Date objects or ISO strings to time display\n * @example formatTimeHHMM(new Date()) => \"14:30\"\n *\n * Note: For formatting seconds (e.g., timer display), use formatTime from utils\n */\nexport function formatTimeHHMM(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })\n}\n\n/**\n * Format a date/time to HH:MM:SS format\n */\nexport function formatTimeWithSeconds(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })\n}\n\n// ============================================================================\n// Contextual Formatting\n// ============================================================================\n\n/**\n * Format a date string for display as a header\n * Returns \"Overdue\", \"Today\", \"Tomorrow\", or formatted date\n */\nexport function formatDateHeader(dateStr: string): string {\n const today = getTodayString()\n\n if (dateStr < today) {\n return 'Overdue'\n }\n\n if (dateStr === today) {\n return 'Today'\n }\n\n const tomorrowStr = getTomorrowString()\n if (dateStr === tomorrowStr) {\n return 'Tomorrow'\n }\n\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'short',\n day: 'numeric',\n })\n}\n\n/**\n * Format a due date for display in task items (simple string version)\n * Returns \"Overdue\", \"Today\", \"Tomorrow\", or formatted date\n *\n * Note: For version that returns { text, isOverdue }, use formatDueDate from utils/formatters\n */\nexport function formatDueDateString(dateStr: string | null): string {\n if (!dateStr) return 'No due date'\n\n const today = getTodayString()\n const tomorrowStr = getTomorrowString()\n\n if (dateStr < today) {\n const date = parseLocalDate(dateStr)\n return `Overdue • ${date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })}`\n }\n\n if (dateStr === today) {\n return 'Today'\n }\n\n if (dateStr === tomorrowStr) {\n return 'Tomorrow'\n }\n\n const date = parseLocalDate(dateStr)\n const currentYear = new Date().getFullYear()\n const dateYear = date.getFullYear()\n\n return date.toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: dateYear !== currentYear ? 'numeric' : undefined,\n })\n}\n\n/**\n * Format a date/time as relative time string (extended version)\n * Accepts both Date objects and ISO strings\n * @example \"Just now\", \"5m ago\", \"2h ago\", \"3d ago\"\n *\n * Note: For simple string input, you can also use formatRelativeTime from utils/formatters\n */\nexport function formatRelativeTimeExtended(dateStr: string | Date): string {\n const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr\n const now = new Date()\n const diffMs = now.getTime() - date.getTime()\n const diffMins = Math.floor(diffMs / 60000)\n const diffHours = Math.floor(diffMins / 60)\n const diffDays = Math.floor(diffHours / 24)\n\n if (diffMins < 1) return 'Just now'\n if (diffMins < 60) return `${diffMins}m ago`\n if (diffHours < 24) return `${diffHours}h ago`\n if (diffDays < 7) return `${diffDays}d ago`\n return date.toLocaleDateString()\n}\n\n/**\n * Format a due date relative to today with contextual prefix\n * @example \"Due today\", \"Due tomorrow\", \"Due in 3 days\", \"2 days overdue\"\n */\nexport function formatRelativeDueDate(\n dateStr: string,\n options?: {\n duePrefix?: string\n overduePrefix?: string\n }\n): string {\n const { duePrefix = 'Due', overduePrefix = '' } = options || {}\n const date = parseLocalDate(dateStr)\n const now = normalizeToMidnight(new Date())\n\n const diffMs = date.getTime() - now.getTime()\n const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24))\n\n if (diffDays < 0) {\n const absDays = Math.abs(diffDays)\n return overduePrefix\n ? `${overduePrefix} ${absDays} day${absDays !== 1 ? 's' : ''} overdue`\n : `${absDays} day${absDays !== 1 ? 's' : ''} overdue`\n }\n if (diffDays === 0) return `${duePrefix} today`\n if (diffDays === 1) return `${duePrefix} tomorrow`\n if (diffDays <= 7) return `${duePrefix} in ${diffDays} days`\n\n return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })\n}\n\n/**\n * Format a pay/income date relative to today\n * @example \"Today\", \"Tomorrow\", \"In 3 days\", \"2 days ago\"\n */\nexport function formatRelativePayDate(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n const now = normalizeToMidnight(new Date())\n\n const diffMs = date.getTime() - now.getTime()\n const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24))\n\n if (diffDays < 0) {\n const absDays = Math.abs(diffDays)\n return `${absDays} day${absDays !== 1 ? 's' : ''} ago`\n }\n if (diffDays === 0) return 'Today'\n if (diffDays === 1) return 'Tomorrow'\n if (diffDays <= 7) return `In ${diffDays} days`\n\n return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })\n}\n\n// ============================================================================\n// Localized Formatting\n// ============================================================================\n\nexport type DateFormat = 'short' | 'medium' | 'long' | 'weekday'\nexport type TimeFormat = 'short' | 'withSeconds'\n\n/**\n * Format a date with various preset formats\n */\nexport function formatDateLocalized(date: Date | string, format: DateFormat = 'medium'): string {\n const d = typeof date === 'string' ? new Date(date) : date\n\n switch (format) {\n case 'short':\n return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })\n case 'medium':\n return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n case 'long':\n return d.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n })\n case 'weekday':\n return d.toLocaleDateString('en-US', { weekday: 'short' })\n default:\n return d.toLocaleDateString()\n }\n}\n\n/**\n * Format a time with various preset formats\n */\nexport function formatTimeLocalized(date: Date | string, format: TimeFormat = 'short'): string {\n const d = typeof date === 'string' ? new Date(date) : date\n\n switch (format) {\n case 'short':\n return d.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true })\n case 'withSeconds':\n return d.toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n })\n default:\n return d.toLocaleTimeString()\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAA,IACH;AACE,aAAO,EAAE,mBAAmB;AAAA,EAChC;AACF;","names":["date"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/date/index.ts"],"sourcesContent":["/**\n * Date Utilities\n *\n * Pure functions for date manipulation and formatting.\n * Works in both Node.js and browser/React Native environments.\n *\n * @example\n * import { getTodayString, addDays, formatRelativeTime } from '@mrck-labs/vanaheim-shared/date'\n *\n * const today = getTodayString() // \"2024-12-16\"\n * const nextWeek = addDays(today, 7) // \"2024-12-23\"\n */\n\n// ============================================================================\n// Core Utilities\n// ============================================================================\n\n/**\n * Normalize a date to midnight (00:00:00.000)\n */\nexport function normalizeToMidnight(date: Date): Date {\n const d = new Date(date)\n d.setHours(0, 0, 0, 0)\n return d\n}\n\n/**\n * Get today's date normalized to midnight\n */\nexport function getTodayMidnight(): Date {\n return normalizeToMidnight(new Date())\n}\n\n/**\n * Format a Date object to YYYY-MM-DD string\n * @example formatDateString(new Date()) => \"2024-12-16\"\n */\nexport function formatDateString(date: Date): string {\n return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`\n}\n\n/**\n * Get today's local date string (YYYY-MM-DD)\n */\nexport function getTodayString(): string {\n return formatDateString(new Date())\n}\n\n/**\n * Parse a YYYY-MM-DD string to a local Date object\n * Avoids timezone issues by appending T00:00:00\n */\nexport function parseLocalDate(dateStr: string): Date {\n return new Date(dateStr + 'T00:00:00')\n}\n\n// ============================================================================\n// Date Checks\n// ============================================================================\n\n/**\n * Check if a date string is today\n */\nexport function isToday(dateStr: string | null): boolean {\n if (!dateStr) return false\n return dateStr === getTodayString()\n}\n\n/**\n * Check if a date string is in the past (before today)\n */\nexport function isOverdue(dateStr: string | null): boolean {\n if (!dateStr) return false\n return dateStr < getTodayString()\n}\n\n/**\n * Check if a date is due within a threshold of days\n * @param dateStr - Date in YYYY-MM-DD format\n * @param daysThreshold - Number of days to check (default: 7)\n */\nexport function isDueSoon(dateStr: string | null, daysThreshold: number = 7): boolean {\n if (!dateStr) return false\n if (isOverdue(dateStr)) return false\n\n const today = getTodayMidnight()\n const targetDate = parseLocalDate(dateStr)\n const diffMs = targetDate.getTime() - today.getTime()\n const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))\n\n return diffDays >= 0 && diffDays <= daysThreshold\n}\n\n// ============================================================================\n// Date Arithmetic\n// ============================================================================\n\n/**\n * Add days to a date string\n * @param dateStr - Date in YYYY-MM-DD format\n * @param days - Number of days to add (can be negative)\n * @returns New date string in YYYY-MM-DD format\n */\nexport function addDays(dateStr: string, days: number): string {\n const date = parseLocalDate(dateStr)\n date.setDate(date.getDate() + days)\n return formatDateString(date)\n}\n\n/**\n * Subtract days from a date string\n */\nexport function subtractDays(dateStr: string, days: number): string {\n return addDays(dateStr, -days)\n}\n\n/**\n * Get yesterday's date string (YYYY-MM-DD)\n */\nexport function getYesterdayString(): string {\n return subtractDays(getTodayString(), 1)\n}\n\n/**\n * Get tomorrow's date string (YYYY-MM-DD)\n */\nexport function getTomorrowString(): string {\n return addDays(getTodayString(), 1)\n}\n\n// ============================================================================\n// ISO String Helpers (for database queries)\n// ============================================================================\n\n/**\n * Get start of day as ISO string\n * @param dateStr - Date in YYYY-MM-DD format\n * @returns ISO string like \"2024-12-15T00:00:00.000Z\"\n */\nexport function getStartOfDayISO(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return new Date(date.getFullYear(), date.getMonth(), date.getDate()).toISOString()\n}\n\n/**\n * Get end of day as ISO string\n * @param dateStr - Date in YYYY-MM-DD format\n * @returns ISO string like \"2024-12-15T23:59:59.999Z\"\n */\nexport function getEndOfDayISO(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return new Date(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n 23,\n 59,\n 59,\n 999\n ).toISOString()\n}\n\n// ============================================================================\n// Week Utilities\n// ============================================================================\n\n/**\n * Get the start of the week (Monday) for a given date\n */\nexport function getWeekStart(date: Date): Date {\n const d = new Date(date)\n const day = d.getDay()\n const diff = d.getDate() - day + (day === 0 ? -6 : 1) // Monday\n d.setDate(diff)\n d.setHours(0, 0, 0, 0)\n return d\n}\n\n/**\n * Get the end of the week (Sunday) for a given week start\n */\nexport function getWeekEnd(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() + 6)\n return d\n}\n\n/**\n * Get the start of the previous week\n */\nexport function getPreviousWeek(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() - 7)\n return d\n}\n\n/**\n * Get the start of the next week\n */\nexport function getNextWeek(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() + 7)\n return d\n}\n\n/**\n * Get start of week (Monday) as date string\n */\nexport function getWeekStartString(baseDate: Date = new Date()): string {\n return formatDateString(getWeekStart(baseDate))\n}\n\n/**\n * Get end of week (Sunday) as date string\n */\nexport function getWeekEndString(baseDate: Date = new Date()): string {\n return formatDateString(getWeekEnd(getWeekStart(baseDate)))\n}\n\n/**\n * Format a week range for display\n * @example \"Dec 2 - 8, 2024\" or \"Nov 25 - Dec 1, 2024\"\n */\nexport function formatWeekRange(weekStart: Date): string {\n const weekEnd = getWeekEnd(weekStart)\n const startMonth = weekStart.toLocaleDateString('en-US', { month: 'short' })\n const endMonth = weekEnd.toLocaleDateString('en-US', { month: 'short' })\n\n if (startMonth === endMonth) {\n return `${startMonth} ${weekStart.getDate()} - ${weekEnd.getDate()}, ${weekStart.getFullYear()}`\n }\n\n return `${startMonth} ${weekStart.getDate()} - ${endMonth} ${weekEnd.getDate()}, ${weekStart.getFullYear()}`\n}\n\n// ============================================================================\n// Display Formatting\n// ============================================================================\n\n/**\n * Format a date string for display with full weekday\n * @example \"Monday, December 15, 2024\"\n */\nexport function formatFullDate(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-US', {\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n })\n}\n\n/**\n * Format date for display in long form\n * @example \"Monday, 9 December\"\n */\nexport function formatDateLong(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-GB', {\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n })\n}\n\n/**\n * Format month and year\n * @example \"December 2024\"\n */\nexport function formatMonthYear(date: Date): string {\n return date.toLocaleDateString('en-US', {\n month: 'long',\n year: 'numeric',\n })\n}\n\n/**\n * Format a date/time to HH:MM format\n */\nexport function formatTimeHHMM(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })\n}\n\n/**\n * Format a date/time to HH:MM:SS format\n */\nexport function formatTimeWithSeconds(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })\n}\n\n// ============================================================================\n// Contextual Formatting\n// ============================================================================\n\n/**\n * Format a date string for display as a header\n * Returns \"Overdue\", \"Today\", \"Tomorrow\", or formatted date\n */\nexport function formatDateHeader(dateStr: string): string {\n const today = getTodayString()\n\n if (dateStr < today) {\n return 'Overdue'\n }\n\n if (dateStr === today) {\n return 'Today'\n }\n\n const tomorrowStr = getTomorrowString()\n if (dateStr === tomorrowStr) {\n return 'Tomorrow'\n }\n\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'short',\n day: 'numeric',\n })\n}\n\n/**\n * Format a due date for display in task items (simple string version)\n * Returns \"Overdue\", \"Today\", \"Tomorrow\", or formatted date\n *\n * Note: For version that returns { text, isOverdue }, use formatDueDate from utils/formatters\n */\nexport function formatDueDateString(dateStr: string | null): string {\n if (!dateStr) return 'No due date'\n\n const today = getTodayString()\n const tomorrowStr = getTomorrowString()\n\n if (dateStr < today) {\n const date = parseLocalDate(dateStr)\n return `Overdue • ${date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })}`\n }\n\n if (dateStr === today) {\n return 'Today'\n }\n\n if (dateStr === tomorrowStr) {\n return 'Tomorrow'\n }\n\n const date = parseLocalDate(dateStr)\n const currentYear = new Date().getFullYear()\n const dateYear = date.getFullYear()\n\n return date.toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: dateYear !== currentYear ? 'numeric' : undefined,\n })\n}\n\n/**\n * Format a date/time as relative time string (extended version)\n * Accepts both Date objects and ISO strings\n * @example \"Just now\", \"5m ago\", \"2h ago\", \"3d ago\"\n *\n * Note: For simple string input, you can also use formatRelativeTime from utils/formatters\n */\nexport function formatRelativeTimeExtended(dateStr: string | Date): string {\n const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr\n const now = new Date()\n const diffMs = now.getTime() - date.getTime()\n const diffMins = Math.floor(diffMs / 60000)\n const diffHours = Math.floor(diffMins / 60)\n const diffDays = Math.floor(diffHours / 24)\n\n if (diffMins < 1) return 'Just now'\n if (diffMins < 60) return `${diffMins}m ago`\n if (diffHours < 24) return `${diffHours}h ago`\n if (diffDays < 7) return `${diffDays}d ago`\n return date.toLocaleDateString()\n}\n\n/**\n * Format a due date relative to today with contextual prefix\n * @example \"Due today\", \"Due tomorrow\", \"Due in 3 days\", \"2 days overdue\"\n */\nexport function formatRelativeDueDate(\n dateStr: string,\n options?: {\n duePrefix?: string\n overduePrefix?: string\n }\n): string {\n const { duePrefix = 'Due', overduePrefix = '' } = options || {}\n const date = parseLocalDate(dateStr)\n const now = normalizeToMidnight(new Date())\n\n const diffMs = date.getTime() - now.getTime()\n const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24))\n\n if (diffDays < 0) {\n const absDays = Math.abs(diffDays)\n return overduePrefix\n ? `${overduePrefix} ${absDays} day${absDays !== 1 ? 's' : ''} overdue`\n : `${absDays} day${absDays !== 1 ? 's' : ''} overdue`\n }\n if (diffDays === 0) return `${duePrefix} today`\n if (diffDays === 1) return `${duePrefix} tomorrow`\n if (diffDays <= 7) return `${duePrefix} in ${diffDays} days`\n\n return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })\n}\n\n/**\n * Format a pay/income date relative to today\n * @example \"Today\", \"Tomorrow\", \"In 3 days\", \"2 days ago\"\n */\nexport function formatRelativePayDate(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n const now = normalizeToMidnight(new Date())\n\n const diffMs = date.getTime() - now.getTime()\n const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24))\n\n if (diffDays < 0) {\n const absDays = Math.abs(diffDays)\n return `${absDays} day${absDays !== 1 ? 's' : ''} ago`\n }\n if (diffDays === 0) return 'Today'\n if (diffDays === 1) return 'Tomorrow'\n if (diffDays <= 7) return `In ${diffDays} days`\n\n return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })\n}\n\n// ============================================================================\n// Localized Formatting\n// ============================================================================\n\nexport type DateFormat = 'short' | 'medium' | 'long' | 'weekday'\nexport type TimeFormat = 'short' | 'withSeconds'\n\n/**\n * Format a date with various preset formats\n */\nexport function formatDateLocalized(date: Date | string, format: DateFormat = 'medium'): string {\n const d = typeof date === 'string' ? new Date(date) : date\n\n switch (format) {\n case 'short':\n return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })\n case 'medium':\n return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n case 'long':\n return d.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n })\n case 'weekday':\n return d.toLocaleDateString('en-US', { weekday: 'short' })\n default:\n return d.toLocaleDateString()\n }\n}\n\n/**\n * Format a time with various preset formats\n */\nexport function formatTimeLocalized(date: Date | string, format: TimeFormat = 'short'): string {\n const d = typeof date === 'string' ? new Date(date) : date\n\n switch (format) {\n case 'short':\n return d.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true })\n case 'withSeconds':\n return d.toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: true,\n })\n default:\n return d.toLocaleTimeString()\n }\n}\n\n"],"mappings":";AAoBO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H;AACE,aAAO,EAAE,mBAAmB;AAAA,EAChC;AACF;","names":["date"]}
1
+ {"version":3,"sources":["../../src/date/index.ts"],"sourcesContent":["/**\n * Date Utilities\n *\n * Pure functions for date manipulation and formatting.\n * Works in both Node.js and browser/React Native environments.\n *\n * @example\n * import { getTodayString, addDays, formatRelativeTime } from '@mrck-labs/vanaheim-shared/date'\n *\n * const today = getTodayString() // \"2024-12-16\"\n * const nextWeek = addDays(today, 7) // \"2024-12-23\"\n */\n\n// ============================================================================\n// Core Utilities\n// ============================================================================\n\n/**\n * Normalize a date to midnight (00:00:00.000)\n */\nexport function normalizeToMidnight(date: Date): Date {\n const d = new Date(date)\n d.setHours(0, 0, 0, 0)\n return d\n}\n\n/**\n * Get today's date normalized to midnight\n */\nexport function getTodayMidnight(): Date {\n return normalizeToMidnight(new Date())\n}\n\n/**\n * Format a Date object to YYYY-MM-DD string\n * @example formatDateString(new Date()) => \"2024-12-16\"\n */\nexport function formatDateString(date: Date): string {\n return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`\n}\n\n/**\n * Get today's local date string (YYYY-MM-DD)\n */\nexport function getTodayString(): string {\n return formatDateString(new Date())\n}\n\n/**\n * Parse a YYYY-MM-DD string to a local Date object\n * Avoids timezone issues by appending T00:00:00\n */\nexport function parseLocalDate(dateStr: string): Date {\n return new Date(dateStr + 'T00:00:00')\n}\n\n// ============================================================================\n// Date Checks\n// ============================================================================\n\n/**\n * Check if a date string is today\n */\nexport function isToday(dateStr: string | null): boolean {\n if (!dateStr) return false\n return dateStr === getTodayString()\n}\n\n/**\n * Check if a date string is in the past (before today)\n */\nexport function isOverdue(dateStr: string | null): boolean {\n if (!dateStr) return false\n return dateStr < getTodayString()\n}\n\n/**\n * Check if a date is due within a threshold of days\n * @param dateStr - Date in YYYY-MM-DD format\n * @param daysThreshold - Number of days to check (default: 7)\n */\nexport function isDueSoon(dateStr: string | null, daysThreshold: number = 7): boolean {\n if (!dateStr) return false\n if (isOverdue(dateStr)) return false\n\n const today = getTodayMidnight()\n const targetDate = parseLocalDate(dateStr)\n const diffMs = targetDate.getTime() - today.getTime()\n const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))\n\n return diffDays >= 0 && diffDays <= daysThreshold\n}\n\n// ============================================================================\n// Date Arithmetic\n// ============================================================================\n\n/**\n * Add days to a date string\n * @param dateStr - Date in YYYY-MM-DD format\n * @param days - Number of days to add (can be negative)\n * @returns New date string in YYYY-MM-DD format\n */\nexport function addDays(dateStr: string, days: number): string {\n const date = parseLocalDate(dateStr)\n date.setDate(date.getDate() + days)\n return formatDateString(date)\n}\n\n/**\n * Subtract days from a date string\n */\nexport function subtractDays(dateStr: string, days: number): string {\n return addDays(dateStr, -days)\n}\n\n/**\n * Get yesterday's date string (YYYY-MM-DD)\n */\nexport function getYesterdayString(): string {\n return subtractDays(getTodayString(), 1)\n}\n\n/**\n * Get tomorrow's date string (YYYY-MM-DD)\n */\nexport function getTomorrowString(): string {\n return addDays(getTodayString(), 1)\n}\n\n// ============================================================================\n// ISO String Helpers (for database queries)\n// ============================================================================\n\n/**\n * Get start of day as ISO string\n * @param dateStr - Date in YYYY-MM-DD format\n * @returns ISO string like \"2024-12-15T00:00:00.000Z\"\n */\nexport function getStartOfDayISO(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return new Date(date.getFullYear(), date.getMonth(), date.getDate()).toISOString()\n}\n\n/**\n * Get end of day as ISO string\n * @param dateStr - Date in YYYY-MM-DD format\n * @returns ISO string like \"2024-12-15T23:59:59.999Z\"\n */\nexport function getEndOfDayISO(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return new Date(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n 23,\n 59,\n 59,\n 999\n ).toISOString()\n}\n\n// ============================================================================\n// Week Utilities\n// ============================================================================\n\n/**\n * Get the start of the week (Monday) for a given date\n */\nexport function getWeekStart(date: Date): Date {\n const d = new Date(date)\n const day = d.getDay()\n const diff = d.getDate() - day + (day === 0 ? -6 : 1) // Monday\n d.setDate(diff)\n d.setHours(0, 0, 0, 0)\n return d\n}\n\n/**\n * Get the end of the week (Sunday) for a given week start\n */\nexport function getWeekEnd(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() + 6)\n return d\n}\n\n/**\n * Get the start of the previous week\n */\nexport function getPreviousWeek(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() - 7)\n return d\n}\n\n/**\n * Get the start of the next week\n */\nexport function getNextWeek(weekStart: Date): Date {\n const d = new Date(weekStart)\n d.setDate(d.getDate() + 7)\n return d\n}\n\n/**\n * Get start of week (Monday) as date string\n */\nexport function getWeekStartString(baseDate: Date = new Date()): string {\n return formatDateString(getWeekStart(baseDate))\n}\n\n/**\n * Get end of week (Sunday) as date string\n */\nexport function getWeekEndString(baseDate: Date = new Date()): string {\n return formatDateString(getWeekEnd(getWeekStart(baseDate)))\n}\n\n/**\n * Format a week range for display\n * @example \"Dec 2 - 8, 2024\" or \"Nov 25 - Dec 1, 2024\"\n */\nexport function formatWeekRange(weekStart: Date): string {\n const weekEnd = getWeekEnd(weekStart)\n const startMonth = weekStart.toLocaleDateString('en-US', { month: 'short' })\n const endMonth = weekEnd.toLocaleDateString('en-US', { month: 'short' })\n\n if (startMonth === endMonth) {\n return `${startMonth} ${weekStart.getDate()} - ${weekEnd.getDate()}, ${weekStart.getFullYear()}`\n }\n\n return `${startMonth} ${weekStart.getDate()} - ${endMonth} ${weekEnd.getDate()}, ${weekStart.getFullYear()}`\n}\n\n// ============================================================================\n// Display Formatting\n// ============================================================================\n\n/**\n * Format a date string for display with full weekday\n * @example \"Monday, December 15, 2024\"\n */\nexport function formatFullDate(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-US', {\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n })\n}\n\n/**\n * Format date for display in long form\n * @example \"Monday, 9 December\"\n */\nexport function formatDateLong(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-GB', {\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n })\n}\n\n/**\n * Format month and year\n * @example \"December 2024\"\n */\nexport function formatMonthYear(date: Date): string {\n return date.toLocaleDateString('en-US', {\n month: 'long',\n year: 'numeric',\n })\n}\n\n/**\n * Format a date/time to HH:MM format\n * Use this for formatting Date objects or ISO strings to time display\n * @example formatTimeHHMM(new Date()) => \"14:30\"\n *\n * Note: For formatting seconds (e.g., timer display), use formatTime from utils\n */\nexport function formatTimeHHMM(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })\n}\n\n/**\n * Format a date/time to HH:MM:SS format\n */\nexport function formatTimeWithSeconds(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })\n}\n\n// ============================================================================\n// Contextual Formatting\n// ============================================================================\n\n/**\n * Format a date string for display as a header\n * Returns \"Overdue\", \"Today\", \"Tomorrow\", or formatted date\n */\nexport function formatDateHeader(dateStr: string): string {\n const today = getTodayString()\n\n if (dateStr < today) {\n return 'Overdue'\n }\n\n if (dateStr === today) {\n return 'Today'\n }\n\n const tomorrowStr = getTomorrowString()\n if (dateStr === tomorrowStr) {\n return 'Tomorrow'\n }\n\n const date = parseLocalDate(dateStr)\n return date.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'short',\n day: 'numeric',\n })\n}\n\n/**\n * Format a due date for display in task items (simple string version)\n * Returns \"Overdue\", \"Today\", \"Tomorrow\", or formatted date\n *\n * Note: For version that returns { text, isOverdue }, use formatDueDate from utils/formatters\n */\nexport function formatDueDateString(dateStr: string | null): string {\n if (!dateStr) return 'No due date'\n\n const today = getTodayString()\n const tomorrowStr = getTomorrowString()\n\n if (dateStr < today) {\n const date = parseLocalDate(dateStr)\n return `Overdue • ${date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })}`\n }\n\n if (dateStr === today) {\n return 'Today'\n }\n\n if (dateStr === tomorrowStr) {\n return 'Tomorrow'\n }\n\n const date = parseLocalDate(dateStr)\n const currentYear = new Date().getFullYear()\n const dateYear = date.getFullYear()\n\n return date.toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: dateYear !== currentYear ? 'numeric' : undefined,\n })\n}\n\n/**\n * Format a date/time as relative time string (extended version)\n * Accepts both Date objects and ISO strings\n * @example \"Just now\", \"5m ago\", \"2h ago\", \"3d ago\"\n *\n * Note: For simple string input, you can also use formatRelativeTime from utils/formatters\n */\nexport function formatRelativeTimeExtended(dateStr: string | Date): string {\n const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr\n const now = new Date()\n const diffMs = now.getTime() - date.getTime()\n const diffMins = Math.floor(diffMs / 60000)\n const diffHours = Math.floor(diffMins / 60)\n const diffDays = Math.floor(diffHours / 24)\n\n if (diffMins < 1) return 'Just now'\n if (diffMins < 60) return `${diffMins}m ago`\n if (diffHours < 24) return `${diffHours}h ago`\n if (diffDays < 7) return `${diffDays}d ago`\n return date.toLocaleDateString()\n}\n\n/**\n * Format a due date relative to today with contextual prefix\n * @example \"Due today\", \"Due tomorrow\", \"Due in 3 days\", \"2 days overdue\"\n */\nexport function formatRelativeDueDate(\n dateStr: string,\n options?: {\n duePrefix?: string\n overduePrefix?: string\n }\n): string {\n const { duePrefix = 'Due', overduePrefix = '' } = options || {}\n const date = parseLocalDate(dateStr)\n const now = normalizeToMidnight(new Date())\n\n const diffMs = date.getTime() - now.getTime()\n const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24))\n\n if (diffDays < 0) {\n const absDays = Math.abs(diffDays)\n return overduePrefix\n ? `${overduePrefix} ${absDays} day${absDays !== 1 ? 's' : ''} overdue`\n : `${absDays} day${absDays !== 1 ? 's' : ''} overdue`\n }\n if (diffDays === 0) return `${duePrefix} today`\n if (diffDays === 1) return `${duePrefix} tomorrow`\n if (diffDays <= 7) return `${duePrefix} in ${diffDays} days`\n\n return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })\n}\n\n/**\n * Format a pay/income date relative to today\n * @example \"Today\", \"Tomorrow\", \"In 3 days\", \"2 days ago\"\n */\nexport function formatRelativePayDate(dateStr: string): string {\n const date = parseLocalDate(dateStr)\n const now = normalizeToMidnight(new Date())\n\n const diffMs = date.getTime() - now.getTime()\n const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24))\n\n if (diffDays < 0) {\n const absDays = Math.abs(diffDays)\n return `${absDays} day${absDays !== 1 ? 's' : ''} ago`\n }\n if (diffDays === 0) return 'Today'\n if (diffDays === 1) return 'Tomorrow'\n if (diffDays <= 7) return `In ${diffDays} days`\n\n return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })\n}\n\n// ============================================================================\n// Localized Formatting\n// ============================================================================\n\nexport type DateFormat = 'short' | 'medium' | 'long' | 'weekday'\nexport type TimeFormat = 'short' | 'withSeconds'\n\n/**\n * Format a date with various preset formats\n */\nexport function formatDateLocalized(date: Date | string, format: DateFormat = 'medium'): string {\n const d = typeof date === 'string' ? new Date(date) : date\n\n switch (format) {\n case 'short':\n return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })\n case 'medium':\n return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n case 'long':\n return d.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n })\n case 'weekday':\n return d.toLocaleDateString('en-US', { weekday: 'short' })\n default:\n return d.toLocaleDateString()\n }\n}\n\n/**\n * Format a time with various preset formats\n */\nexport function formatTimeLocalized(date: Date | string, format: TimeFormat = 'short'): string {\n const d = typeof date === 'string' ? new Date(date) : date\n\n switch (format) {\n case 'short':\n return d.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true })\n case 'withSeconds':\n return d.toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2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AAAA,QACN,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AACE,aAAO,EAAE,mBAAmB;AAAA,EAChC;AACF;","names":["date"]}
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- export { s as BankConnection, B as BankConnectionStatus, t as BankTransaction, k as ChatConversation, m as ChatMessage, C as ChatMessageRole, o as EFLink, u as ExchangeRate, a as Expense, E as ExpenseCategory, F as FocusCategory, h as FocusSession, j as FocusSessionFilters, g as FocusSessionStatus, d as Income, I as IncomeCategory, q as LieuDay, L as LieuDayType, l as NewChatConversation, n as NewChatMessage, p as NewEFLink, b as NewExpense, N as NewExpenseCategory, f as NewFocusCategory, i as NewFocusSession, e as NewIncome, c as NewIncomeCategory, r as NewLieuDay, S as Setting, T as TransactionType } from './database-BKc0Oj26.mjs';
1
+ export { s as BankConnection, B as BankConnectionStatus, t as BankTransaction, k as ChatConversation, m as ChatMessage, C as ChatMessageRole, o as EFLink, K as ExchangeRate, a as Expense, E as ExpenseCategory, F as FocusCategory, h as FocusSession, j as FocusSessionFilters, g as FocusSessionStatus, H as HealthCategory, z as HealthCompletion, G as HealthCompletionFilters, w as HealthFrequencyConfig, v as HealthFrequencyType, x as HealthHabit, D as HealthHabitFilters, J as HealthStats, d as Income, I as IncomeCategory, q as LieuDay, L as LieuDayType, l as NewChatConversation, n as NewChatMessage, p as NewEFLink, b as NewExpense, N as NewExpenseCategory, f as NewFocusCategory, i as NewFocusSession, u as NewHealthCategory, A as NewHealthCompletion, y as NewHealthHabit, e as NewIncome, c as NewIncomeCategory, r as NewLieuDay, S as Setting, T as TransactionType } from './database-3Vv5PNDa.mjs';
2
2
  export { ApiKeyInfo, CloudAgent, CloudAgentConversation, CloudAgentMessage, CloudAgentMessageType, CloudAgentModel, CloudAgentPrompt, CloudAgentSource, CloudAgentStatus, CloudAgentTarget, IssueQueryOptions, LINEAR_PRIORITY_LABELS, LaunchAgentRequest, LinearIssue, LinearPriority, LinearProject, LinearState, LinearStateType, LinearUser, ListAgentsResponse, ModelsResponse, PaginatedIssues } from './types/index.mjs';
3
- export { API_URLS, CLOUD_AGENT_STATUSES, CLOUD_AGENT_STATUS_COLORS, CLOUD_AGENT_STATUS_EMOJI, CURRENCIES, CURRENCY_NAMES, CURRENCY_SYMBOLS, Currency, DEFAULT_FOCUS_DURATIONS, FOCUS_STATUS, FREQUENCIES, FREQUENCY_LABELS, FREQUENCY_MULTIPLIERS, FocusDuration, FocusStatus, Frequency, LINEAR_PRIORITIES, LINEAR_PRIORITY_COLORS, LinearPriorityValue, SETTING_KEYS, SettingKey } from './constants/index.mjs';
4
- export { calculateFocusStats, calculateLieuBalance, calculateMonthlyExpenses, calculateMonthlyIncome, calculateMonthlySavings, calculateSavingsRate, formatCurrency, formatDate, formatDueDate, formatRelativeTime, formatTime, formatTotalTime, generateId, generateRandomColor, generateShortId, getRepoName, isNonEmptyString, isPositiveNumber, isValidCurrency, isValidEmail, isValidFrequency, isValidISODate, isValidUrl, toMonthlyAmount, toYearlyAmount, truncate } from './utils/index.mjs';
3
+ export { API_URLS, CLOUD_AGENT_STATUSES, CLOUD_AGENT_STATUS_COLORS, CLOUD_AGENT_STATUS_EMOJI, CURRENCIES, CURRENCY_NAMES, CURRENCY_SYMBOLS, Currency, DAY_OPTIONS, DEFAULT_FOCUS_DURATIONS, FOCUS_STATUS, FREQUENCIES, FREQUENCY_LABELS, FREQUENCY_MULTIPLIERS, FREQUENCY_OPTIONS, FocusDuration, FocusStatus, Frequency, HEALTH_FREQUENCY_LABELS, HEALTH_FREQUENCY_TYPES, LINEAR_PRIORITIES, LINEAR_PRIORITY_COLORS, LinearPriorityValue, PRESET_COLORS, PRESET_ICONS, SETTING_KEYS, SettingKey } from './constants/index.mjs';
4
+ export { WeeklyProgressItem, calculateFocusStats, calculateLieuBalance, calculateMonthlyExpenses, calculateMonthlyIncome, calculateMonthlySavings, calculateSavingsRate, calculateWeeklyProgress, formatCurrency, formatDate, formatDueDate, formatDuration, formatRelativeTime, formatTime, formatTotalTime, generateId, generateRandomColor, generateShortId, getFrequencyDescription, getRepoName, isNonEmptyString, isPositiveNumber, isValidCurrency, isValidEmail, isValidFrequency, isValidISODate, isValidUrl, parseFrequencyConfig, shouldDoOnDate, shouldDoToday, stringifyFrequencyConfig, toMonthlyAmount, toYearlyAmount, truncate } from './utils/index.mjs';
5
5
  export { QueryKeys, queryKeys } from './query/index.mjs';
6
6
  export { ActiveSession, TimerStatus, activeSessionAtom, elapsedSecondsAtom, formattedElapsedAtom, formattedRemainingAtom, progressAtom, progressPercentAtom, remainingSecondsAtom, targetSecondsAtom, timerStatusAtom } from './atoms/index.mjs';
7
7
  export { DateFormat, TimeFormat, addDays, formatDateHeader, formatDateLocalized, formatDateLong, formatDateString, formatDueDateString, formatFullDate, formatMonthYear, formatRelativeDueDate, formatRelativePayDate, formatRelativeTimeExtended, formatTimeHHMM, formatTimeLocalized, formatTimeWithSeconds, formatWeekRange, getEndOfDayISO, getNextWeek, getPreviousWeek, getStartOfDayISO, getTodayMidnight, getTodayString, getTomorrowString, getWeekEnd, getWeekEndString, getWeekStart, getWeekStartString, getYesterdayString, isDueSoon, isOverdue, isToday, normalizeToMidnight, parseLocalDate, subtractDays } from './date/index.mjs';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { s as BankConnection, B as BankConnectionStatus, t as BankTransaction, k as ChatConversation, m as ChatMessage, C as ChatMessageRole, o as EFLink, u as ExchangeRate, a as Expense, E as ExpenseCategory, F as FocusCategory, h as FocusSession, j as FocusSessionFilters, g as FocusSessionStatus, d as Income, I as IncomeCategory, q as LieuDay, L as LieuDayType, l as NewChatConversation, n as NewChatMessage, p as NewEFLink, b as NewExpense, N as NewExpenseCategory, f as NewFocusCategory, i as NewFocusSession, e as NewIncome, c as NewIncomeCategory, r as NewLieuDay, S as Setting, T as TransactionType } from './database-BKc0Oj26.js';
1
+ export { s as BankConnection, B as BankConnectionStatus, t as BankTransaction, k as ChatConversation, m as ChatMessage, C as ChatMessageRole, o as EFLink, K as ExchangeRate, a as Expense, E as ExpenseCategory, F as FocusCategory, h as FocusSession, j as FocusSessionFilters, g as FocusSessionStatus, H as HealthCategory, z as HealthCompletion, G as HealthCompletionFilters, w as HealthFrequencyConfig, v as HealthFrequencyType, x as HealthHabit, D as HealthHabitFilters, J as HealthStats, d as Income, I as IncomeCategory, q as LieuDay, L as LieuDayType, l as NewChatConversation, n as NewChatMessage, p as NewEFLink, b as NewExpense, N as NewExpenseCategory, f as NewFocusCategory, i as NewFocusSession, u as NewHealthCategory, A as NewHealthCompletion, y as NewHealthHabit, e as NewIncome, c as NewIncomeCategory, r as NewLieuDay, S as Setting, T as TransactionType } from './database-3Vv5PNDa.js';
2
2
  export { ApiKeyInfo, CloudAgent, CloudAgentConversation, CloudAgentMessage, CloudAgentMessageType, CloudAgentModel, CloudAgentPrompt, CloudAgentSource, CloudAgentStatus, CloudAgentTarget, IssueQueryOptions, LINEAR_PRIORITY_LABELS, LaunchAgentRequest, LinearIssue, LinearPriority, LinearProject, LinearState, LinearStateType, LinearUser, ListAgentsResponse, ModelsResponse, PaginatedIssues } from './types/index.js';
3
- export { API_URLS, CLOUD_AGENT_STATUSES, CLOUD_AGENT_STATUS_COLORS, CLOUD_AGENT_STATUS_EMOJI, CURRENCIES, CURRENCY_NAMES, CURRENCY_SYMBOLS, Currency, DEFAULT_FOCUS_DURATIONS, FOCUS_STATUS, FREQUENCIES, FREQUENCY_LABELS, FREQUENCY_MULTIPLIERS, FocusDuration, FocusStatus, Frequency, LINEAR_PRIORITIES, LINEAR_PRIORITY_COLORS, LinearPriorityValue, SETTING_KEYS, SettingKey } from './constants/index.js';
4
- export { calculateFocusStats, calculateLieuBalance, calculateMonthlyExpenses, calculateMonthlyIncome, calculateMonthlySavings, calculateSavingsRate, formatCurrency, formatDate, formatDueDate, formatRelativeTime, formatTime, formatTotalTime, generateId, generateRandomColor, generateShortId, getRepoName, isNonEmptyString, isPositiveNumber, isValidCurrency, isValidEmail, isValidFrequency, isValidISODate, isValidUrl, toMonthlyAmount, toYearlyAmount, truncate } from './utils/index.js';
3
+ export { API_URLS, CLOUD_AGENT_STATUSES, CLOUD_AGENT_STATUS_COLORS, CLOUD_AGENT_STATUS_EMOJI, CURRENCIES, CURRENCY_NAMES, CURRENCY_SYMBOLS, Currency, DAY_OPTIONS, DEFAULT_FOCUS_DURATIONS, FOCUS_STATUS, FREQUENCIES, FREQUENCY_LABELS, FREQUENCY_MULTIPLIERS, FREQUENCY_OPTIONS, FocusDuration, FocusStatus, Frequency, HEALTH_FREQUENCY_LABELS, HEALTH_FREQUENCY_TYPES, LINEAR_PRIORITIES, LINEAR_PRIORITY_COLORS, LinearPriorityValue, PRESET_COLORS, PRESET_ICONS, SETTING_KEYS, SettingKey } from './constants/index.js';
4
+ export { WeeklyProgressItem, calculateFocusStats, calculateLieuBalance, calculateMonthlyExpenses, calculateMonthlyIncome, calculateMonthlySavings, calculateSavingsRate, calculateWeeklyProgress, formatCurrency, formatDate, formatDueDate, formatDuration, formatRelativeTime, formatTime, formatTotalTime, generateId, generateRandomColor, generateShortId, getFrequencyDescription, getRepoName, isNonEmptyString, isPositiveNumber, isValidCurrency, isValidEmail, isValidFrequency, isValidISODate, isValidUrl, parseFrequencyConfig, shouldDoOnDate, shouldDoToday, stringifyFrequencyConfig, toMonthlyAmount, toYearlyAmount, truncate } from './utils/index.js';
5
5
  export { QueryKeys, queryKeys } from './query/index.js';
6
6
  export { ActiveSession, TimerStatus, activeSessionAtom, elapsedSecondsAtom, formattedElapsedAtom, formattedRemainingAtom, progressAtom, progressPercentAtom, remainingSecondsAtom, targetSecondsAtom, timerStatusAtom } from './atoms/index.js';
7
7
  export { DateFormat, TimeFormat, addDays, formatDateHeader, formatDateLocalized, formatDateLong, formatDateString, formatDueDateString, formatFullDate, formatMonthYear, formatRelativeDueDate, formatRelativePayDate, formatRelativeTimeExtended, formatTimeHHMM, formatTimeLocalized, formatTimeWithSeconds, formatWeekRange, getEndOfDayISO, getNextWeek, getPreviousWeek, getStartOfDayISO, getTodayMidnight, getTodayString, getTomorrowString, getWeekEnd, getWeekEndString, getWeekStart, getWeekStartString, getYesterdayString, isDueSoon, isOverdue, isToday, normalizeToMidnight, parseLocalDate, subtractDays } from './date/index.js';