From ba795bcab7261669db8a5584629ec5b05394ed05 Mon Sep 17 00:00:00 2001 From: mopquill <1709954+mopquill@users.noreply.github.com> Date: Fri, 26 Mar 2021 08:01:12 -0600 Subject: [PATCH] Merged 0.4.2 from upstream master, added UTC changes to main.ts for transpiling --- manifest.json | 2 +- src/main.ts | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 0d2c80e..8b1789d 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "id": "nldates-obsidian", "name": "Natural Language Dates", "description": "Create date-links based on natural language", - "version": "0.4.2", + "version": "0.4.2-mopquill.1", "author": "Argentina Ortega Sainz", "authorUrl": "", "isDesktopOnly": false, diff --git a/src/main.ts b/src/main.ts index 471c6b2..a9263b7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -87,6 +87,13 @@ export default class NaturalLanguageDates extends Plugin { hotkeys: [], }); + this.addCommand({ + id: "nlp-now-utc", + name: "Insert the current date and time in UTC", + callback: () => this.getNowUTCCommand(), + hotkeys: [], + }); + this.addCommand({ id: "nlp-today", name: "Insert the current date", @@ -212,6 +219,10 @@ export default class NaturalLanguageDates extends Plugin { return (window as any).moment(date); } + getUTCMoment(date: Date): any { + return (window as any).moment.utc(date); + } + getFormattedDate(date: Date): string { var formattedDate = this.getMoment(date).format(this.settings.format); return formattedDate; @@ -312,6 +323,16 @@ export default class NaturalLanguageDates extends Plugin { ); } + getNowUTCCommand() { + let activeLeaf: any = this.app.workspace.activeLeaf; + let editor = activeLeaf.view.sourceMode.cmEditor; + editor.replaceSelection( + this.getUTCMoment(new Date()).format( + `${this.settings.format}${this.settings.separator}${this.settings.timeFormat}` + ) + ); + } + getDateCommand() { let activeLeaf: any = this.app.workspace.activeLeaf; let editor = activeLeaf.view.sourceMode.cmEditor;