From 5ba4099b31626d970c55e8968b19f852411f5c6a Mon Sep 17 00:00:00 2001 From: Tom Herdson Date: Tue, 16 Feb 2021 23:24:53 +1300 Subject: [PATCH] Use date format from settings --- package.json | 2 +- src/index.ts | 13 ++++++++----- src/manifest.json | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b7edb03..a3ba611 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "joplin-plugin-insert-date", - "version": "1.0.0", + "version": "1.0.1", "scripts": { "dist": "webpack --joplin-plugin-config buildMain && webpack --joplin-plugin-config buildExtraScripts && webpack --joplin-plugin-config createArchive", "prepare": "npm run dist", diff --git a/src/index.ts b/src/index.ts index 885edaa..b65fa81 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,15 @@ import joplin from 'api'; import { ToolbarButtonLocation } from 'api/types'; -const moment = require('moment'); - -function formatMsToLocal(ms: number) { - return moment(ms).format('DD/MM/YYYY'); -} +import * as moment from 'moment'; joplin.plugins.register({ onStart: async function() { + + var dateFormat = await joplin.settings.globalValue('dateFormat'); + + const formatMsToLocal = (ms: number) => { + return moment(ms).format(dateFormat); + } await joplin.commands.register({ name: 'insertDate', @@ -21,4 +23,5 @@ joplin.plugins.register({ await joplin.views.toolbarButtons.create('insertDate', 'insertDate', ToolbarButtonLocation.EditorToolbar); }, + }); diff --git a/src/manifest.json b/src/manifest.json index 08e4336..08a28b0 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 1, "id": "joplin-insert-date", "app_min_version": "1.7", - "version": "1.0.0", + "version": "1.0.1", "name": "Insert Date", "description": "Adds a button to insert the current date (without time) into the editor.", "author": "herdsothom",