Date to/from as a title (script?)

Is it too complex to write a script that:

  1. Searches for the last Monday (e.g. 16 April) and the next Sunday (e.g. 21 April)
  2. adds it as the first line in the draft as 16/04 - 21/04

Alternatively, if easier, could I use the date prompt, select date 1 and date 2 and have a draft with title date1 - date2 in format dd/mm?

Any help is very welcome! Thanks

The Date.js library that ships with Drafts 5 is great for stuff like this…to get you started try:

var d1 = Date.parse("last monday");
var d2 = Date.parse("sunday");

alert(d1 + "\n" + d2);

Some more details here.

1 Like