-
-
Save jermspeaks/669b6232060a86b81bfc271fea0e2622 to your computer and use it in GitHub Desktop.
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
<%* | |
const dateFormat = "YYYY-MM-DD"; | |
const dateBasisStr = await tp.system.prompt("When is the meeting?"); | |
if (dateBasisStr) { | |
function createMessage(daysBefore, dateFormat, dateBasisStr) { | |
let parseResult; | |
let newDate; | |
let parseResultLink; | |
let nlDatesPlugin = app.plugins.getPlugin('nldates-obsidian'); | |
parseResult = nlDatesPlugin.parseDate(dateBasisStr); | |
newDate = window.moment(parseResult.formattedString).add((daysBefore * -1), 'days').format(dateFormat); | |
if (newDate) { | |
if (newDate !== 'Invalid date') { parseResultLink = '[' + '[' + newDate + ']]'; } | |
} | |
if (parseResultLink) { | |
return parseResultLink; | |
} else { | |
return ""; | |
} | |
} | |
let msgDate; | |
msgDate = createMessage(14, dateFormat, dateBasisStr); | |
tR += `Send agenda on ${msgDate}` | |
//Repeat to add multiple lines / dates | |
msgDate = createMessage(7, dateFormat, dateBasisStr); | |
tR += `\n`; | |
tR += `Send reminder on ${msgDate}` | |
msgDate = createMessage(1, dateFormat, dateBasisStr); | |
tR += `\n`; | |
tR += `Tomorrow is the meeting! ${msgDate} will remind me!` | |
} | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment