Skip to content

Commit

Permalink
update packages; use luxon for dates
Browse files Browse the repository at this point in the history
  • Loading branch information
sphars committed Feb 28, 2024
1 parent d7e07e8 commit bb65642
Show file tree
Hide file tree
Showing 6 changed files with 270 additions and 1,615 deletions.
7 changes: 3 additions & 4 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const pluginRSS = require('@11ty/eleventy-plugin-rss');
const moment = require('moment');
moment.locale('en');
const { DateTime } = require('luxon');

module.exports = function(eleventyConfig) {
// allows templates to add additional data
Expand All @@ -18,12 +17,12 @@ module.exports = function(eleventyConfig) {

// filter to return a date as ISO string objects
eleventyConfig.addFilter('dateISO', date => {
return moment(date).toISOString();
return DateTime.fromJSDate(date).toISO();
});

// filter to return a date for prettier display. Uses UTC to avoid timezone differences
eleventyConfig.addFilter('datePretty', date => {
return moment(date).utc().format('LL'); // e.g. May 16, 2020
return DateTime.fromJSDate(date).toUTC().toLocaleString(DateTime.DATE_FULL); // e.g. May 16, 2020
});

// filter to sort a list of posts by date desc
Expand Down
Loading

0 comments on commit bb65642

Please sign in to comment.