mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-23 00:16:25 +01:00
Revert "Add try catch to toLocaleString"
This reverts commit 1208a9ac02
.
This commit is contained in:
parent
28a1210dc4
commit
b5a6eeef42
@ -62,7 +62,7 @@ export const toSelectablePeriod = (
|
||||
dayCount,
|
||||
label:
|
||||
label ||
|
||||
date.toLocaleString('en-US', { month: 'long', year: 'numeric' }),
|
||||
"date.toLocaleString('en-US', { month: 'long', year: 'numeric' })",
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -2,22 +2,14 @@ export const formatDateYMDHMS = (
|
||||
date: number | string | Date,
|
||||
locale?: string,
|
||||
): string => {
|
||||
try {
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Invalid toLocaleString locale: ${locale}, date: ${date}`,
|
||||
e,
|
||||
);
|
||||
return '';
|
||||
}
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
});
|
||||
};
|
||||
|
||||
export const formatDateYMDHM = (
|
||||
@ -25,22 +17,14 @@ export const formatDateYMDHM = (
|
||||
locale: string,
|
||||
timeZone?: string,
|
||||
): string => {
|
||||
try {
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
timeZone,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Invalid toLocaleString locale: ${locale}, date: ${date}`,
|
||||
e,
|
||||
);
|
||||
return '';
|
||||
}
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
timeZone,
|
||||
});
|
||||
};
|
||||
|
||||
export const formatDateYMD = (
|
||||
@ -48,36 +32,20 @@ export const formatDateYMD = (
|
||||
locale: string,
|
||||
timeZone?: string,
|
||||
): string => {
|
||||
try {
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
timeZone,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Invalid toLocaleString locale: ${locale}, date: ${date}`,
|
||||
e,
|
||||
);
|
||||
return '';
|
||||
}
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
timeZone,
|
||||
});
|
||||
};
|
||||
|
||||
export const formatDateHM = (
|
||||
date: number | string | Date,
|
||||
locale: string,
|
||||
): string => {
|
||||
try {
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Invalid toLocaleString locale: ${locale}, date: ${date}`,
|
||||
e,
|
||||
);
|
||||
return '';
|
||||
}
|
||||
return new Date(date).toLocaleString(locale, {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user