huridocs/uwazi

View on GitHub
app/react/V2/shared/dateHelpers.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { DateTime } from 'luxon';

const secondsToDate = (timestamp: number | string, locale?: string) =>
  DateTime.fromSeconds(Number(timestamp))
    .setZone('UTC')
    .toLocaleString(DateTime.DATE_FULL, { locale: locale || 'en' });

const secondsToISODate = (timestamp: number | string) =>
  DateTime.fromSeconds(Number(timestamp)).setZone('UTC').toISODate();

export { secondsToDate, secondsToISODate };