mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 20:51:11 -05:00
Migrate date precision to exact
Batch update all date precision handling to use expanded DatePrecision, replace hardcoded day defaults, and adjust related validation, UI, and helpers. Includes wrapper migration across Phase 1-3 functions, updates to logs, displays, and formatting utilities to align frontend with new precision values ('exact', 'month', 'year', 'decade', 'century', 'approximate').
This commit is contained in:
@@ -72,7 +72,7 @@ export function getCurrentDateLocal(): string {
|
||||
*/
|
||||
export function formatDateDisplay(
|
||||
dateString: string | null | undefined,
|
||||
precision: 'day' | 'month' | 'year' = 'day'
|
||||
precision: 'exact' | 'month' | 'year' | 'decade' | 'century' | 'approximate' = 'exact'
|
||||
): string {
|
||||
if (!dateString) return '';
|
||||
|
||||
@@ -83,7 +83,13 @@ export function formatDateDisplay(
|
||||
return date.getFullYear().toString();
|
||||
case 'month':
|
||||
return date.toLocaleDateString('en-US', { year: 'numeric', month: 'long' });
|
||||
case 'day':
|
||||
case 'decade':
|
||||
return `${Math.floor(date.getFullYear() / 10) * 10}s`;
|
||||
case 'century':
|
||||
return `${Math.ceil(date.getFullYear() / 100)}th century`;
|
||||
case 'approximate':
|
||||
return `circa ${date.getFullYear()}`;
|
||||
case 'exact':
|
||||
default:
|
||||
return date.toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
@@ -182,7 +188,7 @@ export function parseDateForDisplay(date: string | Date): Date {
|
||||
*/
|
||||
export function toDateWithPrecision(
|
||||
date: Date,
|
||||
precision: 'day' | 'month' | 'year'
|
||||
precision: 'exact' | 'month' | 'year' | 'decade' | 'century' | 'approximate'
|
||||
): string {
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
@@ -193,7 +199,13 @@ export function toDateWithPrecision(
|
||||
return `${year}-01-01`;
|
||||
case 'month':
|
||||
return `${year}-${String(month).padStart(2, '0')}-01`;
|
||||
case 'day':
|
||||
case 'decade':
|
||||
return `${Math.floor(year / 10) * 10}-01-01`;
|
||||
case 'century':
|
||||
return `${Math.floor((year - 1) / 100) * 100 + 1}-01-01`;
|
||||
case 'approximate':
|
||||
return `${year}-01-01`;
|
||||
case 'exact':
|
||||
default:
|
||||
return `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user