diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2021-12-05 20:54:58 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2021-12-05 20:54:58 -0400 |
commit | 139b212438b18cce8bdfa171008f3b7ea07876bc (patch) | |
tree | 11c59443cdbde29a9a83055e29d48b7d5590a3d6 | |
parent | adbeabeb7961a68b86cd09df254548c04e947670 (diff) |
originalDate data cleanup stuff
-rwxr-xr-x | src/upd8.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/upd8.js b/src/upd8.js index e9b3d4ec..291f110c 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -886,9 +886,19 @@ async function processAlbumDataFile(file) { getBasicField(section, 'FG') || album.color ), + originalDate: getBasicField(section, 'Original Date'), startIndex: trackIndex, tracks: [] }; + if (group.originalDate) { + if (isNaN(Date.parse(group.originalDate))) { + return {error: `The track group "${group.name}" has an invalid "Original Date" field: "${group.originalDate}"`}; + } + group.originalDate = new Date(group.originalDate); + group.date = group.originalDate; + } else { + group.date = album.date; + } if (album.trackGroups) { album.trackGroups.push(group); } else { @@ -962,7 +972,11 @@ async function processAlbumDataFile(file) { if (isNaN(Date.parse(track.originalDate))) { return {error: `The track "${track.name}"'s has an invalid "Original Date" field: "${track.originalDate}"`}; } + track.originalDate = new Date(track.originalDate); track.date = new Date(track.originalDate); + } else if (group && group.originalDate) { + track.originalDate = group.originalDate; + track.date = group.originalDate; } else { track.date = album.date; } @@ -2848,7 +2862,7 @@ async function main() { writes = buildStepsWithTargets.flatMap(({ flag, pageSpec, targets }) => { const writes = targets.flatMap(target => - pageSpec.write(target, {wikiData}).slice() || []); + pageSpec.write(target, {wikiData})?.slice() || []); if (!validateWrites(writes, flag + '.write')) { return []; |