lewisdale.dev/config/filters/dates.js
2023-12-30 15:38:09 +00:00

21 lines
657 B
JavaScript

module.exports = function(eleventyConfig) {
eleventyConfig.addFilter('parseDate', dateString => new Date(dateString));
eleventyConfig.addFilter('dateDisplay', date => new Date(date).toLocaleDateString('en-GB', {
"dateStyle": "short"
}));
eleventyConfig.addFilter('dateTimeDisplay', date => new Date(date).toLocaleString('en-GB', {
'dateStyle': 'short',
'timeStyle': 'short',
}));
eleventyConfig.addFilter('timeDisplay', date => new Date(date).toLocaleTimeString('en-GB', {
'hour': '2-digit',
'minute': 'numeric',
'hour12': true
}));
// eleventyConfig.addFilter('rfc3339', date => new Date(date).toISOString());
}