Skip to content

Commit

Permalink
Merged 0.4.2 from upstream master, added UTC changes to main.ts for t…
Browse files Browse the repository at this point in the history
…ranspiling
  • Loading branch information
mpql committed Mar 26, 2021
1 parent 5fd4b01 commit ba795bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ba795bc

Please sign in to comment.