Challenge: Text Snippet with Today’s Date Inserted Automatically

Hello. As the typical preface, I know very little about the topics that I am seeking help for. The variables are just too complicated for my skillset.

Here is what I am hoping for:
I want to create an automated snippet of text that can be pasted with indentations in place. Here is the snippet:

#[[Inbox]]
	Query
		{{[[query]]: {and: [[Inbox]] [[TODO]] {and: {not: [[query]]} {not: [[^today]] }}}}}
#[[Quick Capture]]
#[[Upcomoing]]
	{{[[query]]: {and: [[TODO]] {not: [[query]]} {between: [[^today]] [[^today+7days]]}}}}
#[[Action List]]
	#[[Priority]] Today
		#[[Scheduled]]
			{{[[query]]: {and: [[TODO]] [[^today]] {not: [[query]] [[#Inbox]]}}}}
		#[[Email]]
			{{[[TODO]]}} Process [[Canvas]]
			{{[[TODO]]}} Process Standard
		#[[Courses]]
		#[[Family]] #[[Home]]
	#[[InProgress]]
		#Action
			{{[[query]]: {and: [[TODO]] [[InProgress]] [[Action]]{not: [[query]]}}}}
		### All Others
			{{[[query]]: {and: [[TODO]] [[InProgress]] {or: {not: #Action} {not: [[query]]}}}}
	#[[Maybe]]
#[[Daily Notes]]
#[[Class Notes]]
#[[Evening Review]]

HOWEVER, what I would like is for every ^Today, I would like today’s date inserted in a particular format; Month day(st, nd, rd, th), 4-digit year. (e.g. April 10th, 2020) For this I have a Drafts snippet that formats it correctly, but I can’t figure out how to expand it within the snippet above.

function insertTextPosAtEnd(p_strText) {
	editor.setSelectedText(p_strText);
	editor.setSelectedRange(editor.getSelectedRange()[0] + editor.getSelectedRange()[1], 0);
	editor.activate();
}

function getOrdinalNum(n) {
  return n + (n > 0 ? ['th', 'st', 'nd', 'rd'][(n > 3 && n < 21) || n % 10 > 3 ? 0 : n % 10] : '');
}

const monthNames = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"
];

var today = new Date();
var m = monthNames[today.getMonth()];
var d = getOrdinalNum(today.getDate());
var y = today.getFullYear();

var ordinalToday = "[[" + m + " " + d + ", " + y + "]]";
insertTextPosAtEnd(ordinalToday);
draft.update();

For bonus points, I also want to take the given date of today and add a number of days to it and have it output the future date in the same formate mentioned above.

Bret Terpstra has a Keyboard Maestro macro for the date, and a Textexpander version. But in either case, I don’t know how to incorporate that into a single flow.

I am more familiar with iOS shortcuts, and it wouldn’t hurt to have it there too. But I am hoping to get either a Textexpander snippet to do it, or a Keyboard Maestro macro, or hell I even have Alfred too! Any way that this is possible I will get it into my workflow, whether on iOS or macOS.

Any ideas or assistance would be greatly appreciated. For full disclosure, this is for RoamResearch.com 's app - Roam and my daily template.

1 Like