mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
Revert "Add try catches everywhere and defaults for locales"
This reverts commit f62dbe6917
.
This commit is contained in:
parent
5b64b4cdd0
commit
28a1210dc4
@ -47,18 +47,6 @@ const calculateTrafficDataCost = (trafficData: number) => {
|
||||
const padMonth = (month: number): string =>
|
||||
month < 10 ? `0${month}` : `${month}`;
|
||||
|
||||
const safeLocaleString = (date: Date): string => {
|
||||
try {
|
||||
return date.toLocaleString('en-US', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(`Invalid toLocaleString locale: en-US, date: ${date}`, e);
|
||||
return '';
|
||||
}
|
||||
};
|
||||
export const toSelectablePeriod = (
|
||||
date: Date,
|
||||
label?: string,
|
||||
@ -72,7 +60,9 @@ export const toSelectablePeriod = (
|
||||
year,
|
||||
month,
|
||||
dayCount,
|
||||
label: label || safeLocaleString(date),
|
||||
label:
|
||||
label ||
|
||||
date.toLocaleString('en-US', { month: 'long', year: 'numeric' }),
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@ export const formatDateYMDHMS = (
|
||||
locale?: string,
|
||||
): string => {
|
||||
try {
|
||||
return new Date(date).toLocaleString(locale ?? 'en-US', {
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
@ -26,7 +26,7 @@ export const formatDateYMDHM = (
|
||||
timeZone?: string,
|
||||
): string => {
|
||||
try {
|
||||
return new Date(date).toLocaleString(locale ?? 'en-US', {
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
@ -49,7 +49,7 @@ export const formatDateYMD = (
|
||||
timeZone?: string,
|
||||
): string => {
|
||||
try {
|
||||
return new Date(date).toLocaleString(locale ?? 'en-US', {
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
@ -69,7 +69,7 @@ export const formatDateHM = (
|
||||
locale: string,
|
||||
): string => {
|
||||
try {
|
||||
return new Date(date).toLocaleString(locale ?? 'en-US', {
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user