You've already forked joplin
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user