This commit is contained in:
2025-11-15 04:11:22 +01:00
parent bd3eab8b40
commit d0379c57ce
47 changed files with 558 additions and 703 deletions
+6 -6
View File
@@ -1,4 +1,4 @@
const ensureDate = (value: string | number | Date | null | undefined): Date | null => {
const ensureDate = (value: string | number | Date | null): Date | null => {
if (!value) {
return null;
}
@@ -12,7 +12,7 @@ interface FormatOptions {
options?: Intl.DateTimeFormatOptions;
}
export const formatDate = (value: string | number | Date | null | undefined, { fallback = '—', locale, options }: FormatOptions = {}): string => {
export const formatDate = (value: string | number | Date | null, { fallback = '—', locale, options }: FormatOptions = {}): string => {
const date = ensureDate(value);
if (!date) {
return fallback;
@@ -20,7 +20,7 @@ export const formatDate = (value: string | number | Date | null | undefined, { f
return date.toLocaleDateString(locale, options);
};
export const formatDateTime = (value: string | number | Date | null | undefined, { fallback = '—', locale, options }: FormatOptions = {}): string => {
export const formatDateTime = (value: string | number | Date | null, { fallback = '—', locale, options }: FormatOptions = {}): string => {
const date = ensureDate(value);
if (!date) {
return fallback;
@@ -28,7 +28,7 @@ export const formatDateTime = (value: string | number | Date | null | undefined,
return date.toLocaleString(locale, options);
};
export const toDateInputValue = (value: string | number | Date | null | undefined): string => {
export const toDateInputValue = (value: string | number | Date | null): string => {
const date = ensureDate(value);
if (!date) {
return '';
@@ -38,7 +38,7 @@ export const toDateInputValue = (value: string | number | Date | null | undefine
return localDate.toISOString().slice(0, 10);
};
export const toIssuedTimestamp = (dateString: string | null | undefined, fallback: string | number | Date | null | undefined): string | null => {
export const toIssuedTimestamp = (dateString: string | null, fallback: string | number | Date | null): string | null => {
if (!dateString) {
return null;
}
@@ -52,7 +52,7 @@ export const toIssuedTimestamp = (dateString: string | null | undefined, fallbac
return Number.isNaN(candidate.getTime()) ? null : candidate.toISOString();
};
export const parseDateValue = (value: string | number | Date | null | undefined): Date | null => ensureDate(value);
export const parseDateValue = (value: string | number | Date | null): Date | null => ensureDate(value);
export default {
formatDate,