init
This commit is contained in:
18
src/utils/utils.ts
Normal file
18
src/utils/utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export const formatAmount = (amount: number) => {
|
||||
return new Intl.NumberFormat('ru-RU').format(amount);
|
||||
};
|
||||
|
||||
export const formatDate = (date) => {
|
||||
const validDate = typeof date === 'string' ? new Date(date) : date;
|
||||
|
||||
// Проверяем, является ли validDate корректной датой
|
||||
if (isNaN(validDate.getTime())) {
|
||||
return 'Invalid Date'; // Если дата неверная, возвращаем текст ошибки
|
||||
}
|
||||
|
||||
return validDate.toLocaleDateString('ru-RU', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: '2-digit',
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user