1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

All: Fixes #557: Handle ENEX am-pm date format

This commit is contained in:
Laurent Cozic
2018-06-10 01:19:24 +01:00
parent f47610e6fd
commit b0e57a5990
3 changed files with 29 additions and 15 deletions

View File

@@ -17,11 +17,18 @@ const md5 = require('md5');
const fs = require('fs-extra');
function dateToTimestamp(s, zeroIfInvalid = false) {
// Most dates seem to be in this format
let m = moment(s, 'YYYYMMDDTHHmmssZ');
// But sometimes they might be in this format eg. 20180306T91108 AMZ
// https://github.com/laurent22/joplin/issues/557
if (!m.isValid()) m = moment(s, 'YYYYMMDDThmmss AZ');
if (!m.isValid()) {
if (zeroIfInvalid) return 0;
throw new Error('Invalid date: ' + s);
}
return m.toDate().getTime();
}