mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
Merge pull request #4255 from Compositr/master
Add new datePattern and monthPattern replacers
This commit is contained in:
commit
65e53741e7
@ -29,6 +29,13 @@ function createNote(parentNote, noteTitle) {
|
||||
}).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} */
|
||||
function getRootCalendarNote() {
|
||||
let rootNote;
|
||||
@ -98,6 +105,8 @@ function getMonthNoteTitle(rootNote, monthNumber, dateObj) {
|
||||
const monthName = MONTHS[dateObj.getMonth()];
|
||||
|
||||
return pattern
|
||||
.replace(/{shortMonth3}/g, monthName.slice(0,3))
|
||||
.replace(/{shortMonth4}/g, monthName.slice(0,4))
|
||||
.replace(/{monthNumberPadded}/g, monthNumber)
|
||||
.replace(/{month}/g, monthName);
|
||||
}
|
||||
@ -145,6 +154,7 @@ function getDayNoteTitle(rootNote, dayNumber, dateObj) {
|
||||
const weekDay = DAYS[dateObj.getDay()];
|
||||
|
||||
return pattern
|
||||
.replace(/{ordinal}/g, ordinal(parseInt(dayNumber)))
|
||||
.replace(/{dayInMonthPadded}/g, dayNumber)
|
||||
.replace(/{isoDate}/g, dateUtils.utcDateStr(dateObj))
|
||||
.replace(/{weekDay}/g, weekDay)
|
||||
|
Loading…
x
Reference in New Issue
Block a user