Skip to content

Instantly share code, notes, and snippets.

@GitMurf
Created April 22, 2021 19:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GitMurf/de74ea0a297f44041034bb97170357f0 to your computer and use it in GitHub Desktop.
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.
<%*
//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;
%>
@GitMurf
Copy link
Author

GitMurf commented Apr 22, 2021

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

@GitMurf
Copy link
Author

GitMurf commented Apr 22, 2021

TIP: Copying and pasting into Obsidian as Plain Text seems to work best (ctrl/cmd + shift + v)

@megclaypool
Copy link

megclaypool commented Jul 21, 2022

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