Add support for formatting ISO dates
This commit is contained in:
parent
18d99cfe6c
commit
d48a11c9a2
|
@ -12,8 +12,12 @@ export default function(eleventyConfig) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Format dates
|
// Format dates
|
||||||
eleventyConfig.addFilter("formatDate", (dateObj) => {
|
eleventyConfig.addFilter("formatDate", (date) => {
|
||||||
return DateTime.fromJSDate(dateObj).toFormat("d LLLL yyyy");
|
const dateFormat = "d LLLL yyyy";
|
||||||
|
if (typeof date === "object") {
|
||||||
|
return DateTime.fromJSDate(date).toFormat(dateFormat);
|
||||||
|
}
|
||||||
|
return DateTime.fromISO(date, { setZone: true }).toFormat(dateFormat);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Limit number of items displayed
|
// Limit number of items displayed
|
||||||
|
|
Loading…
Reference in New Issue