1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-15 01:16:22 +02:00

Revert "Add try catch to toLocaleString"

This reverts commit 1208a9ac02.
This commit is contained in:
Gastón Fournier 2024-09-02 17:31:10 +02:00
parent 28a1210dc4
commit b5a6eeef42
No known key found for this signature in database
GPG Key ID: AF45428626E17A8E
2 changed files with 27 additions and 59 deletions

View File

@ -62,7 +62,7 @@ export const toSelectablePeriod = (
dayCount, dayCount,
label: label:
label || label ||
date.toLocaleString('en-US', { month: 'long', year: 'numeric' }), "date.toLocaleString('en-US', { month: 'long', year: 'numeric' })",
}; };
}; };

View File

@ -2,7 +2,6 @@ export const formatDateYMDHMS = (
date: number | string | Date, date: number | string | Date,
locale?: string, locale?: string,
): string => { ): string => {
try {
return new Date(date).toLocaleString(locale, { return new Date(date).toLocaleString(locale, {
day: '2-digit', day: '2-digit',
month: '2-digit', month: '2-digit',
@ -11,13 +10,6 @@ export const formatDateYMDHMS = (
minute: '2-digit', minute: '2-digit',
second: '2-digit', second: '2-digit',
}); });
} catch (e) {
console.error(
`Invalid toLocaleString locale: ${locale}, date: ${date}`,
e,
);
return '';
}
}; };
export const formatDateYMDHM = ( export const formatDateYMDHM = (
@ -25,7 +17,6 @@ export const formatDateYMDHM = (
locale: string, locale: string,
timeZone?: string, timeZone?: string,
): string => { ): string => {
try {
return new Date(date).toLocaleString(locale, { return new Date(date).toLocaleString(locale, {
day: '2-digit', day: '2-digit',
month: '2-digit', month: '2-digit',
@ -34,13 +25,6 @@ export const formatDateYMDHM = (
minute: '2-digit', minute: '2-digit',
timeZone, timeZone,
}); });
} catch (e) {
console.error(
`Invalid toLocaleString locale: ${locale}, date: ${date}`,
e,
);
return '';
}
}; };
export const formatDateYMD = ( export const formatDateYMD = (
@ -48,36 +32,20 @@ export const formatDateYMD = (
locale: string, locale: string,
timeZone?: string, timeZone?: string,
): string => { ): string => {
try {
return new Date(date).toLocaleString(locale, { return new Date(date).toLocaleString(locale, {
day: '2-digit', day: '2-digit',
month: '2-digit', month: '2-digit',
year: 'numeric', year: 'numeric',
timeZone, timeZone,
}); });
} catch (e) {
console.error(
`Invalid toLocaleString locale: ${locale}, date: ${date}`,
e,
);
return '';
}
}; };
export const formatDateHM = ( export const formatDateHM = (
date: number | string | Date, date: number | string | Date,
locale: string, locale: string,
): string => { ): string => {
try {
return new Date(date).toLocaleString(locale, { return new Date(date).toLocaleString(locale, {
hour: '2-digit', hour: '2-digit',
minute: '2-digit', minute: '2-digit',
}); });
} catch (e) {
console.error(
`Invalid toLocaleString locale: ${locale}, date: ${date}`,
e,
);
return '';
}
}; };