2023-01-30 02:38:45 +01:00
|
|
|
import html from '../utils/html.js'
|
|
|
|
|
2023-09-28 02:50:43 +02:00
|
|
|
/**
|
|
|
|
* @param {string} dateString
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2023-01-30 02:38:45 +01:00
|
|
|
const formatDate = dateString =>
|
|
|
|
new Date(dateString).toLocaleDateString('en', {
|
|
|
|
month: 'short',
|
|
|
|
year: 'numeric',
|
|
|
|
timeZone: 'UTC',
|
|
|
|
})
|
|
|
|
|
2023-09-28 02:50:43 +02:00
|
|
|
/**
|
|
|
|
* @param {string} date
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2023-01-30 02:38:45 +01:00
|
|
|
export default function Duration(date) {
|
|
|
|
return html`<time datetime="${date}">${formatDate(date)}</time>`
|
|
|
|
}
|