json-theme-even-fork/components/date.js

21 lines
410 B
JavaScript
Raw Normal View History

import html from '../utils/html.js'
/**
* @param {string} dateString
* @returns {string}
*/
const formatDate = dateString =>
new Date(dateString).toLocaleDateString('en', {
month: 'short',
year: 'numeric',
timeZone: 'UTC',
})
/**
* @param {string} date
* @returns {string}
*/
export default function Duration(date) {
return html`<time datetime="${date}">${formatDate(date)}</time>`
}