@cranberry-money/shared-utils
Version:
Shared utility functions for Blueberry platform
34 lines • 1.47 kB
TypeScript
import type { TimeRange } from '@cranberry-money/shared-constants';
/**
* Format a date string for display (e.g., "8 January 2026").
* Unified function for use across all projects.
*/
export declare function formatDate(dateString: string | null | undefined, fallback?: string, locale?: string): string;
/**
* Format a date string to short format (e.g., "Jan 8").
*/
export declare function formatShortDate(dateString: string | null | undefined, fallback?: string, locale?: string): string;
/**
* Format a date string to time only (e.g., "14:30").
*/
export declare function formatTime(dateString: string | null | undefined, fallback?: string, locale?: string): string;
/**
* Format a date string with date and time (e.g., "Jan 8, 2026, 14:30").
*/
export declare function formatDateTime(dateString: string | null | undefined, fallback?: string, locale?: string): string;
export interface DateRange {
start_date: string | undefined;
end_date: string | undefined;
}
export declare function getDateRange(timeRange: TimeRange): DateRange;
/**
* Parse a YYYY-MM-DD date string into a Date object.
* Returns undefined if the string is empty or invalid.
*/
export declare function parseDateString(dateString: string): Date | undefined;
/**
* Format a Date object to a YYYY-MM-DD string.
* Returns an empty string if the date is undefined.
*/
export declare function formatDateToString(date: Date | undefined): string;
//# sourceMappingURL=date.d.ts.map