mirror of
https://github.com/zadam/trilium.git
synced 2024-09-20 07:35:59 +08:00
small refactor of ordinal() func
This commit is contained in:
parent
6dd466ddaf
commit
809ffa0c6e
|
@ -1,12 +1,10 @@
|
|||
"use strict";
|
||||
|
||||
const noteService = require('./notes');
|
||||
const becca = require('../becca/becca');
|
||||
const attributeService = require('./attributes');
|
||||
const dateUtils = require('./date_utils');
|
||||
const sql = require('./sql');
|
||||
const protectedSessionService = require('./protected_session');
|
||||
const cls = require("./cls");
|
||||
const searchService = require('../services/search/services/search');
|
||||
const SearchContext = require('../services/search/search_context');
|
||||
const hoistedNoteService = require("./hoisted_note");
|
||||
|
@ -29,13 +27,6 @@ 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;
|
||||
|
@ -162,6 +153,14 @@ function getDayNoteTitle(rootNote, dayNumber, dateObj) {
|
|||
.replace(/{weekDay2}/g, weekDay.substr(0, 2));
|
||||
}
|
||||
|
||||
/** produces 1st, 2nd, 3rd, 4th, 21st, 31st for 1, 2, 3, 4, 21, 31 */
|
||||
function ordinal(dayNumber) {
|
||||
const suffixes = ["th", "st", "nd", "rd"];
|
||||
const suffix = suffixes[(dayNumber - 20) % 10] || suffixes[dayNumber] || suffixes[0];
|
||||
|
||||
return `${dayNumber}${suffix}`;
|
||||
}
|
||||
|
||||
/** @returns {BNote} */
|
||||
function getDayNote(dateStr, rootNote = null) {
|
||||
if (!rootNote) {
|
||||
|
|
Loading…
Reference in a new issue