fix: format-date without localizing
This commit is contained in:
parent
3321395b7f
commit
88f9fdd25c
@ -31,6 +31,7 @@
|
||||
"clsx": "^2.1.1",
|
||||
"cookies-next": "^5.1.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"date-fns-tz": "^3.2.0",
|
||||
"embla-carousel-autoplay": "^8.6.0",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
"json-to-graphql-query": "^2.3.0",
|
||||
|
||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@ -71,6 +71,9 @@ importers:
|
||||
date-fns:
|
||||
specifier: ^4.1.0
|
||||
version: 4.1.0
|
||||
date-fns-tz:
|
||||
specifier: ^3.2.0
|
||||
version: 3.2.0(date-fns@4.1.0)
|
||||
embla-carousel-autoplay:
|
||||
specifier: ^8.6.0
|
||||
version: 8.6.0(embla-carousel@8.6.0)
|
||||
@ -1570,6 +1573,11 @@ packages:
|
||||
resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
date-fns-tz@3.2.0:
|
||||
resolution: {integrity: sha512-sg8HqoTEulcbbbVXeg84u5UnlsQa8GS5QXMqjjYIhS4abEVVKIUwe0/l/UhrZdKaL/W5eWZNlbTeEIiOXTcsBQ==}
|
||||
peerDependencies:
|
||||
date-fns: ^3.0.0 || ^4.0.0
|
||||
|
||||
date-fns@4.1.0:
|
||||
resolution: {integrity: sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==}
|
||||
|
||||
@ -4228,6 +4236,10 @@ snapshots:
|
||||
es-errors: 1.3.0
|
||||
is-data-view: 1.0.2
|
||||
|
||||
date-fns-tz@3.2.0(date-fns@4.1.0):
|
||||
dependencies:
|
||||
date-fns: 4.1.0
|
||||
|
||||
date-fns@4.1.0: {}
|
||||
|
||||
debug@3.2.7:
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { deleteCookie } from 'cookies-next';
|
||||
import { format } from 'date-fns';
|
||||
import { Building2, LogOut, Wallet } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
@ -12,6 +11,7 @@ import {
|
||||
import { CorporateTransactionRequest } from '@/entities/corporate/model/types/corporate-transactions.type';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { formatDate } from '@/shared/lib/format-date';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import {
|
||||
Card,
|
||||
@ -195,7 +195,7 @@ export function CorporateDashboard() {
|
||||
renderRow={(transaction, index) => (
|
||||
<TableRow key={index}>
|
||||
<TableCell>
|
||||
{format(
|
||||
{formatDate(
|
||||
new Date(transaction.date_create),
|
||||
'dd.MM.yyyy HH:mm',
|
||||
)}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { deleteCookie } from 'cookies-next';
|
||||
import { format } from 'date-fns';
|
||||
import { ArrowUpRight, Clock, CreditCard, LogOut, User } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
@ -13,6 +12,7 @@ import { BonusTransactionRequest } from '@/entities/bonus/model/types/bonus-tran
|
||||
|
||||
import Loader from '@/shared/components/loader';
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { formatDate } from '@/shared/lib/format-date';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import {
|
||||
Card,
|
||||
@ -190,10 +190,7 @@ export function CustomerDashboard() {
|
||||
renderRow={(transaction) => (
|
||||
<TableRow key={transaction.id}>
|
||||
<TableCell>
|
||||
{format(
|
||||
new Date(transaction.date_create),
|
||||
'dd.MM.yyyy HH:mm',
|
||||
)}
|
||||
{formatDate(transaction.date_create, 'dd.MM.yyyy HH:mm')}
|
||||
</TableCell>
|
||||
<TableCell>{transaction.station}</TableCell>
|
||||
<TableCell>{transaction.product_name}</TableCell>
|
||||
|
||||
9
src/shared/lib/format-date.ts
Normal file
9
src/shared/lib/format-date.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { formatInTimeZone } from 'date-fns-tz';
|
||||
|
||||
export const formatDate = (
|
||||
date: Date | string,
|
||||
formatStr: string = 'dd.MM.yyyy HH:mm',
|
||||
) => {
|
||||
const utcDate = new Date(date);
|
||||
return formatInTimeZone(utcDate, 'UTC', formatStr);
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user