lewisdale.dev/config/filters/dates.js
Lewis Dale e0c315d837
Some checks failed
Build and copy to prod / build-and-copy (push) Has been cancelled
Upgrade to Eleventy 3.0.0
2024-10-06 12:36:54 +01:00

29 lines
853 B
JavaScript

export default 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.addGlobalData('isCSSNakedDay', () => {
const dateObj = new Date();
return dateObj.getMonth() === 3 && dateObj.getFullYear() === 2024 && dateObj.getDate() === 9;
});
// eleventyConfig.addFilter('rfc3339', date => new Date(date).toISOString());
}