From ef8ecc452cdfbe4d0bb93412e3d65cd5869fcf39 Mon Sep 17 00:00:00 2001 From: Jin <22962980+JYC333@users.noreply.github.com> Date: Tue, 1 Apr 2025 00:08:48 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20fix=20minor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/date_notes.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/services/date_notes.ts b/src/services/date_notes.ts index 1324de89b..a0292fc1e 100644 --- a/src/services/date_notes.ts +++ b/src/services/date_notes.ts @@ -1,5 +1,3 @@ -"use strict"; - import noteService from "./notes.js"; import attributeService from "./attributes.js"; import dateUtils from "./date_utils.js"; @@ -80,7 +78,7 @@ function getRootCalendarNote(): BNote { function getYearNote(dateStr: string, _rootNote: BNote | null = null): BNote { const rootNote = _rootNote || getRootCalendarNote(); - const yearStr = dateStr.trim().substr(0, 4); + const yearStr = dateStr.trim().substring(0, 4); let yearNote = searchService.findFirstNoteWithQuery(`#${YEAR_LABEL}="${yearStr}"`, new SearchContext({ ancestorNoteId: rootNote.noteId })); @@ -119,8 +117,8 @@ function getMonthNoteTitle(rootNote: BNote, monthNumber: string, dateObj: Date) function getMonthNote(dateStr: string, _rootNote: BNote | null = null): BNote { const rootNote = _rootNote || getRootCalendarNote(); - const monthStr = dateStr.substr(0, 7); - const monthNumber = dateStr.substr(5, 2); + const monthStr = dateStr.substring(0, 7); + const monthNumber = dateStr.substring(5, 2); let monthNote = searchService.findFirstNoteWithQuery(`#${MONTH_LABEL}="${monthStr}"`, new SearchContext({ ancestorNoteId: rootNote.noteId })); @@ -159,8 +157,8 @@ function getDayNoteTitle(rootNote: BNote, dayNumber: string, dateObj: Date) { .replace(/{dayInMonthPadded}/g, dayNumber) .replace(/{isoDate}/g, dateUtils.utcDateStr(dateObj)) .replace(/{weekDay}/g, weekDay) - .replace(/{weekDay3}/g, weekDay.substr(0, 3)) - .replace(/{weekDay2}/g, weekDay.substr(0, 2)); + .replace(/{weekDay3}/g, weekDay.substring(0, 3)) + .replace(/{weekDay2}/g, weekDay.substring(0, 2)); } /** produces 1st, 2nd, 3rd, 4th, 21st, 31st for 1, 2, 3, 4, 21, 31 */ @@ -174,7 +172,7 @@ function ordinal(dayNumber: number) { function getDayNote(dateStr: string, _rootNote: BNote | null = null): BNote { const rootNote = _rootNote || getRootCalendarNote(); - dateStr = dateStr.trim().substr(0, 10); + dateStr = dateStr.trim().substring(0, 10); let dateNote = searchService.findFirstNoteWithQuery(`#${DATE_LABEL}="${dateStr}"`, new SearchContext({ ancestorNoteId: rootNote.noteId })); @@ -183,7 +181,7 @@ function getDayNote(dateStr: string, _rootNote: BNote | null = null): BNote { } const monthNote = getMonthNote(dateStr, rootNote); - const dayNumber = dateStr.substr(8, 2); + const dayNumber = dateStr.substring(8, 2); const dateObj = dateUtils.parseLocalDate(dateStr); @@ -192,7 +190,7 @@ function getDayNote(dateStr: string, _rootNote: BNote | null = null): BNote { sql.transactional(() => { dateNote = createNote(monthNote, noteTitle); - attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr.substr(0, 10)); + attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr.substring(0, 10)); const dateTemplateAttr = rootNote.getOwnedAttribute("relation", "dateTemplate");