Last active
June 20, 2021 22:07
-
-
Save GitMurf/9b85fcc31f2f553365ca4765eb5dabb8 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
@kmaustral I just updated the code to allow for adding multiple lines with different dates and messages. It uses a function now so can just repeat as few or many times as you want by copying these 3 lines and repeating: