diff --git a/src/becca/similarity.js b/src/becca/similarity.js index 5835ca629..bb3320cde 100644 --- a/src/becca/similarity.js +++ b/src/becca/similarity.js @@ -178,10 +178,10 @@ function buildDateLimits(baseNote) { const dateCreatedTs = dateUtils.parseDateTime(baseNote.utcDateCreated).getTime(); return { - minDate: dateUtils.utcDateStr(new Date(dateCreatedTs - 3600 * 1000)), - minExcludedDate: dateUtils.utcDateStr(new Date(dateCreatedTs - 5 * 1000)), - maxExcludedDate: dateUtils.utcDateStr(new Date(dateCreatedTs + 5 * 1000)), - maxDate: dateUtils.utcDateStr(new Date(dateCreatedTs + 3600 * 1000)), + minDate: dateUtils.utcDateTimeStr(new Date(dateCreatedTs - 3600 * 1000)), + minExcludedDate: dateUtils.utcDateTimeStr(new Date(dateCreatedTs - 5 * 1000)), + maxExcludedDate: dateUtils.utcDateTimeStr(new Date(dateCreatedTs + 5 * 1000)), + maxDate: dateUtils.utcDateTimeStr(new Date(dateCreatedTs + 3600 * 1000)), }; } diff --git a/src/routes/api/recent_notes.js b/src/routes/api/recent_notes.js index 41abc6eb1..ff641ecf9 100644 --- a/src/routes/api/recent_notes.js +++ b/src/routes/api/recent_notes.js @@ -12,7 +12,7 @@ function addRecentNote(req) { if (Math.random() < 0.05) { // it's not necessary to run this everytime ... - const cutOffDate = dateUtils.utcDateStr(new Date(Date.now() - 24 * 3600 * 1000)); + const cutOffDate = dateUtils.utcDateTimeStr(new Date(Date.now() - 24 * 3600 * 1000)); sql.execute(`DELETE FROM recent_notes WHERE utcDateCreated < ?`, [cutOffDate]); } diff --git a/src/services/date_notes.js b/src/services/date_notes.js index 7d44dac17..ef0ea63fd 100644 --- a/src/services/date_notes.js +++ b/src/services/date_notes.js @@ -146,7 +146,7 @@ function getDateNoteTitle(rootNote, dayNumber, dateObj) { return pattern .replace(/{dayInMonthPadded}/g, dayNumber) - .replace(/{isoDate}/g, dateUtils.localNowDate()) + .replace(/{isoDate}/g, dateUtils.utcDateTimeStr(dateObj)) .replace(/{weekDay}/g, weekDay) .replace(/{weekDay3}/g, weekDay.substr(0, 3)) .replace(/{weekDay2}/g, weekDay.substr(0, 2)); @@ -215,7 +215,7 @@ function getWeekNote(dateStr, options = {}) { const dateObj = getStartOfTheWeek(dateUtils.parseLocalDate(dateStr), startOfTheWeek); - dateStr = dateUtils.utcDateStr(dateObj); + dateStr = dateUtils.utcDateTimeStr(dateObj); return getDateNote(dateStr); } diff --git a/src/services/date_utils.js b/src/services/date_utils.js index cc84ca5b0..2a5637139 100644 --- a/src/services/date_utils.js +++ b/src/services/date_utils.js @@ -2,7 +2,7 @@ const dayjs = require('dayjs'); const cls = require('./cls'); function utcNowDateTime() { - return utcDateStr(new Date()); + return utcDateTimeStr(new Date()); } // CLS date time is important in web deployments - server often runs in different time zone than user is located in @@ -30,7 +30,7 @@ function pad(num) { return num <= 9 ? `0${num}` : `${num}`; } -function utcDateStr(date) { +function utcDateTimeStr(date) { return date.toISOString().replace('T', ' '); } @@ -68,9 +68,9 @@ module.exports = { utcNowDateTime, localNowDateTime, localNowDate, - utcDateStr, + utcDateTimeStr, parseDate, parseDateTime, parseLocalDate, getDateTimeForFile -}; \ No newline at end of file +}; diff --git a/src/services/notes.js b/src/services/notes.js index 7ccdf8a61..3200e3bce 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -466,7 +466,7 @@ function saveNoteRevision(note) { const now = new Date(); const noteRevisionSnapshotTimeInterval = parseInt(optionService.getOption('noteRevisionSnapshotTimeInterval')); - const revisionCutoff = dateUtils.utcDateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000)); + const revisionCutoff = dateUtils.utcDateTimeStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000)); const existingNoteRevisionId = sql.getValue( "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND utcDateCreated >= ?", [note.noteId, revisionCutoff]); @@ -730,15 +730,15 @@ function eraseDeletedEntities(eraseEntitiesAfterTimeInSeconds = null) { const cutoffDate = new Date(Date.now() - eraseEntitiesAfterTimeInSeconds * 1000); - const noteIdsToErase = sql.getColumn("SELECT noteId FROM notes WHERE isDeleted = 1 AND utcDateModified <= ?", [dateUtils.utcDateStr(cutoffDate)]); + const noteIdsToErase = sql.getColumn("SELECT noteId FROM notes WHERE isDeleted = 1 AND utcDateModified <= ?", [dateUtils.utcDateTimeStr(cutoffDate)]); eraseNotes(noteIdsToErase); - const branchIdsToErase = sql.getColumn("SELECT branchId FROM branches WHERE isDeleted = 1 AND utcDateModified <= ?", [dateUtils.utcDateStr(cutoffDate)]); + const branchIdsToErase = sql.getColumn("SELECT branchId FROM branches WHERE isDeleted = 1 AND utcDateModified <= ?", [dateUtils.utcDateTimeStr(cutoffDate)]); eraseBranches(branchIdsToErase); - const attributeIdsToErase = sql.getColumn("SELECT attributeId FROM attributes WHERE isDeleted = 1 AND utcDateModified <= ?", [dateUtils.utcDateStr(cutoffDate)]); + const attributeIdsToErase = sql.getColumn("SELECT attributeId FROM attributes WHERE isDeleted = 1 AND utcDateModified <= ?", [dateUtils.utcDateTimeStr(cutoffDate)]); eraseAttributes(attributeIdsToErase); }