Advanced settings for date and time formatting

This commit is contained in:
Will Boyd
2020-12-22 10:21:44 -05:00
parent 7fea897840
commit 9e6d38adc9
2 changed files with 19 additions and 1 deletions
+10 -1
View File
@@ -3,6 +3,7 @@ const luxon = require('luxon');
const xml2js = require('xml2js');
const shared = require('./shared');
const settings = require('./settings');
const translator = require('./translator');
async function parseFilePromise(config) {
@@ -82,7 +83,15 @@ function getPostTitle(post) {
}
function getPostDate(post) {
return luxon.DateTime.fromRFC2822(post.pubDate[0], { zone: 'utc' }).toISO();
const dateTime = luxon.DateTime.fromRFC2822(post.pubDate[0], { zone: 'utc' });
if (settings.custom_date_formatting) {
return dateTime.toFormat(settings.custom_date_formatting);
} else if (settings.include_time_with_date) {
return dateTime.toISO();
} else {
return dateTime.toISODate();
}
}
function getCategories(post) {
+9
View File
@@ -5,3 +5,12 @@ exports.image_file_request_delay = 500;
// time in ms to wait between saving Markdown files
// increase this if your file system becomes overloaded
exports.markdown_file_write_delay = 25;
// enable this to include time with post dates
// for example, "2020-12-25" would become "2020-12-25T11:20:35.000Z"
exports.include_time_with_date = false;
// override post date formatting with a custom formatting string (for example: 'yyyy LLL dd')
// tokens are documented here: https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens
// if set, this takes precedence over include_time_with_date
exports.custom_date_formatting = '';