Created
April 22, 2021 19:04
-
-
Save GitMurf/de74ea0a297f44041034bb97170357f0 to your computer and use it in GitHub Desktop.
Requires @argenos Natural Language Dates Plugin. Pop up input box asks for date and then parses it as a date and turns it into a [[Daily Notes Page]] page ref.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
//v1.0 | |
let dueDateStr = await tp.system.prompt("Due Date"); | |
let parseResult; | |
let parseResultLink; | |
if(dueDateStr) { | |
let nlDatesPlugin = this.app.plugins.getPlugin('nldates-obsidian'); | |
parseResult = nlDatesPlugin.parseDate(dueDateStr); | |
if(parseResult){parseResultLink = '[' + '[' + parseResult.formattedString + ']]';} | |
} | |
tR = parseResultLink; | |
%> |
TIP: Copying and pasting into Obsidian as Plain Text seems to work best (ctrl/cmd + shift + v)
Thanks so much -- I've got a little templater snippet I use to convert a selected date into a link to that day's daily note, but I wanted to be able to use natural language processing instead of always having to format my input date very specifically. I had the Natural Language Dates plugin, but didn't know how to access it from my template. You provided the crucial last piece of the puzzle! :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is link to @argenos Natural Language Dates plugin which is required for this Templater script to run.
https://github.com/argenos/nldates-obsidian#natural-language-dates-in-obsidian