Help with date format

Is that a Roman numeral? In a date? I’m not sure I want to know the story behind this requirement. That said, I’m pretty sure strftime does not support directly, so it would probably require a script. If it’s only the month you need to convert, that’s not too bad. I might keep it simple and do a replacement table, like:

const months = {
  "01": "i",
  "02": "ii",
  "03": "iii",
  "04": "iv",
  "05": "v",
  "06": "vi",
  "07": "vii",
  "08": "viii",
  "09": "ix",
  "10": "x",
  "11": "xi",
  "12": "xii"
}
// get date like 02/03/2021
let d = draft.processTemplate("[[date|%d/%m/%Y]]");
// replace month
for (let m in months) {
	d = d.replace(`/${m}/`, `/${months[m]}/`);
}

let [st,len] = editor.getSelectedRange();
editor.setSelectedText(d);
editor.setSelectedRange(st+d.length, 0);

Looks like the good Dr. beat to me to it, but either of these would work.

1 Like