UNPKG

@prezly/theme-kit-ui

Version:
19 lines 639 B
import React from "react"; import { format } from 'date-fns'; // FIXME: avoid importing all locales import * as locales from 'date-fns/locale'; export function StoryPublicationDate(_ref) { var { publishedAt, locale: currentLocale, dateFormat = 'd/MM/YY' } = _ref; if (!publishedAt) { return null; } var date = typeof publishedAt === 'string' ? new Date(publishedAt) : new Date(publishedAt * 1000); var locale = currentLocale ? locales[currentLocale] : undefined; return /*#__PURE__*/React.createElement(React.Fragment, null, format(date, dateFormat.replace('D', 'd').replace('YY', 'yy'), { locale })); }