mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-06-05 15:09:59 +09:00
Advanced settings for date and time formatting
This commit is contained in:
+10
-1
@@ -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) {
|
||||
|
||||
@@ -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 = '';
|
||||
|
||||
Reference in New Issue
Block a user