mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 19:51:57 +08:00
utcDateStr => utcDateTimeStr
This commit is contained in:
parent
a9df0c485f
commit
57b7f6199e
5 changed files with 15 additions and 15 deletions
|
@ -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)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue