mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
feat: add new datePattern replacer {ordinal}
* {ordinal} is replaced with the ordinal date (e.g. 1st, 2nd, 3rd) etc.
This commit is contained in:
parent
9413cd2296
commit
81d64e020e
@ -29,6 +29,13 @@ function createNote(parentNote, noteTitle) {
|
|||||||
}).note;
|
}).note;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ordinal(n) {
|
||||||
|
var s = ["th", "st", "nd", "rd"],
|
||||||
|
v = n % 100;
|
||||||
|
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @returns {BNote} */
|
/** @returns {BNote} */
|
||||||
function getRootCalendarNote() {
|
function getRootCalendarNote() {
|
||||||
let rootNote;
|
let rootNote;
|
||||||
@ -145,6 +152,7 @@ function getDayNoteTitle(rootNote, dayNumber, dateObj) {
|
|||||||
const weekDay = DAYS[dateObj.getDay()];
|
const weekDay = DAYS[dateObj.getDay()];
|
||||||
|
|
||||||
return pattern
|
return pattern
|
||||||
|
.replace(/{ordinal}/g, ordinal(parseInt(dayNumber)))
|
||||||
.replace(/{dayInMonthPadded}/g, dayNumber)
|
.replace(/{dayInMonthPadded}/g, dayNumber)
|
||||||
.replace(/{isoDate}/g, dateUtils.utcDateStr(dateObj))
|
.replace(/{isoDate}/g, dateUtils.utcDateStr(dateObj))
|
||||||
.replace(/{weekDay}/g, weekDay)
|
.replace(/{weekDay}/g, weekDay)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user