MVP Build
This commit is contained in:
31
backend/src/shared-minimal/utils/formatters.ts
Normal file
31
backend/src/shared-minimal/utils/formatters.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @ai-summary Generic formatting utilities (no business logic)
|
||||
* @ai-context Pure functions only, no feature-specific logic
|
||||
*/
|
||||
|
||||
export function formatDate(date: Date): string {
|
||||
return date.toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
export function formatDateTime(date: Date): string {
|
||||
return date.toISOString();
|
||||
}
|
||||
|
||||
export function formatCurrency(amount: number, currency = 'USD'): string {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency,
|
||||
}).format(amount);
|
||||
}
|
||||
|
||||
export function formatDistance(meters: number): string {
|
||||
if (meters < 1000) {
|
||||
return `${Math.round(meters)}m`;
|
||||
}
|
||||
return `${(meters / 1000).toFixed(1)}km`;
|
||||
}
|
||||
|
||||
export function formatMPG(miles: number, gallons: number): string {
|
||||
if (gallons === 0) return '0 MPG';
|
||||
return `${(miles / gallons).toFixed(1)} MPG`;
|
||||
}
|
||||
Reference in New Issue
Block a user