Files
klz-cables.com/.pnpm-store/v10/files/3c/f4dcc0794d6c7d962d69473e5faa1b2a2be4759b0f38ab16be9e83fc5a4d56dc435519466aa986ad974c042810cfc48eb109fbe93cd0f9cc27cadf1b55ec4c
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

33 lines
1.2 KiB
Plaintext

import { TZDateMini as TZDate } from '@date-fns/tz/date/mini';
import { format, formatDistanceToNow, transpose } from 'date-fns';
export const formatDate = ({
date,
i18n,
pattern,
timezone
}) => {
const theDate = new TZDate(new Date(date));
if (timezone) {
const DateWithOriginalTz = TZDate.tz(timezone);
const modifiedDate = theDate.withTimeZone(timezone);
// Transpose the date to the selected timezone
const dateWithTimezone = transpose(modifiedDate, DateWithOriginalTz);
// Transpose the date to the user's timezone - this is necessary because the react-datepicker component insists on displaying the date in the user's timezone
return i18n.dateFNS ? format(dateWithTimezone, pattern, {
locale: i18n.dateFNS
}) : `${i18n.t('general:loading')}...`;
}
return i18n.dateFNS ? format(theDate, pattern, {
locale: i18n.dateFNS
}) : `${i18n.t('general:loading')}...`;
};
export const formatTimeToNow = ({
date,
i18n
}) => {
const theDate = typeof date === 'string' ? new Date(date) : date;
return i18n?.dateFNS ? formatDistanceToNow(theDate, {
locale: i18n.dateFNS
}) : `${i18n.t('general:loading')}...`;
};
//# sourceMappingURL=formatDateTitle.js.map