mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-26 21:12:59 +02:00
All: Fixes #557: Handle ENEX am-pm date format
This commit is contained in:
parent
f47610e6fd
commit
b0e57a5990
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
START_DIR="$(pwd)"
|
||||
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
BUILD_DIR="$ROOT_DIR/tests-build"
|
||||
TEST_FILE="$1"
|
||||
@ -13,15 +14,22 @@ if [[ $TEST_FILE != "" ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
(cd "$ROOT_DIR" && npm test tests-build/ArrayUtils.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/encryption.js
|
||||
(cd "$ROOT_DIR" && npm test tests-build/EnexToMd.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/HtmlToMd.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/markdownUtils.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/models_Folder.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/models_Note.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/models_Setting.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/services_InteropService.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/services_ResourceService.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/synchronizer.js)
|
||||
(cd "$ROOT_DIR" && npm test tests-build/urlUtils.js)
|
||||
function finish {
|
||||
cd "$START_DIR"
|
||||
}
|
||||
|
||||
trap finish EXIT
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
npm test tests-build/ArrayUtils.js
|
||||
npm test tests-build/encryption.js
|
||||
npm test tests-build/EnexToMd.js
|
||||
npm test tests-build/HtmlToMd.js
|
||||
npm test tests-build/markdownUtils.js
|
||||
npm test tests-build/models_Folder.js
|
||||
npm test tests-build/models_Note.js
|
||||
npm test tests-build/models_Setting.js
|
||||
npm test tests-build/services_InteropService.js
|
||||
npm test tests-build/services_ResourceService.js
|
||||
npm test tests-build/synchronizer.js
|
||||
npm test tests-build/urlUtils.js
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@ const { time } = require('lib/time-utils.js');
|
||||
const { setLocale, defaultLocale, closestSupportedLocale } = require('lib/locale.js');
|
||||
const { FsDriverNode } = require('lib/fs-driver-node.js');
|
||||
const mimeUtils = require('lib/mime-utils.js').mime;
|
||||
const Note = require('lib/models/Note.js');
|
||||
const Resource = require('lib/models/Resource.js');
|
||||
const urlValidator = require('valid-url');
|
||||
|
||||
function shimInit() {
|
||||
@ -82,7 +84,6 @@ function shimInit() {
|
||||
await shim.writeImageToFile(image, mime, targetPath);
|
||||
} else { // For the CLI tool
|
||||
const sharp = require('sharp');
|
||||
const Resource = require('lib/models/Resource.js');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
sharp(filePath)
|
||||
@ -104,11 +105,9 @@ function shimInit() {
|
||||
const readChunk = require('read-chunk');
|
||||
const imageType = require('image-type');
|
||||
|
||||
const Resource = require('lib/models/Resource.js');
|
||||
const { uuid } = require('lib/uuid.js');
|
||||
const { basename, fileExtension, safeFileExtension } = require('lib/path-utils.js');
|
||||
const mime = require('mime/lite');
|
||||
const Note = require('lib/models/Note.js');
|
||||
|
||||
if (!(await fs.pathExists(filePath))) throw new Error(_('Cannot access %s', filePath));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user