mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
utcDateStr => utcDateTimeStr
This commit is contained in:
parent
a9df0c485f
commit
57b7f6199e
@ -178,10 +178,10 @@ function buildDateLimits(baseNote) {
|
|||||||
const dateCreatedTs = dateUtils.parseDateTime(baseNote.utcDateCreated).getTime();
|
const dateCreatedTs = dateUtils.parseDateTime(baseNote.utcDateCreated).getTime();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
minDate: dateUtils.utcDateStr(new Date(dateCreatedTs - 3600 * 1000)),
|
minDate: dateUtils.utcDateTimeStr(new Date(dateCreatedTs - 3600 * 1000)),
|
||||||
minExcludedDate: dateUtils.utcDateStr(new Date(dateCreatedTs - 5 * 1000)),
|
minExcludedDate: dateUtils.utcDateTimeStr(new Date(dateCreatedTs - 5 * 1000)),
|
||||||
maxExcludedDate: dateUtils.utcDateStr(new Date(dateCreatedTs + 5 * 1000)),
|
maxExcludedDate: dateUtils.utcDateTimeStr(new Date(dateCreatedTs + 5 * 1000)),
|
||||||
maxDate: dateUtils.utcDateStr(new Date(dateCreatedTs + 3600 * 1000)),
|
maxDate: dateUtils.utcDateTimeStr(new Date(dateCreatedTs + 3600 * 1000)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ function addRecentNote(req) {
|
|||||||
|
|
||||||
if (Math.random() < 0.05) {
|
if (Math.random() < 0.05) {
|
||||||
// it's not necessary to run this everytime ...
|
// 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]);
|
sql.execute(`DELETE FROM recent_notes WHERE utcDateCreated < ?`, [cutOffDate]);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ function getDateNoteTitle(rootNote, dayNumber, dateObj) {
|
|||||||
|
|
||||||
return pattern
|
return pattern
|
||||||
.replace(/{dayInMonthPadded}/g, dayNumber)
|
.replace(/{dayInMonthPadded}/g, dayNumber)
|
||||||
.replace(/{isoDate}/g, dateUtils.localNowDate())
|
.replace(/{isoDate}/g, dateUtils.utcDateTimeStr(dateObj))
|
||||||
.replace(/{weekDay}/g, weekDay)
|
.replace(/{weekDay}/g, weekDay)
|
||||||
.replace(/{weekDay3}/g, weekDay.substr(0, 3))
|
.replace(/{weekDay3}/g, weekDay.substr(0, 3))
|
||||||
.replace(/{weekDay2}/g, weekDay.substr(0, 2));
|
.replace(/{weekDay2}/g, weekDay.substr(0, 2));
|
||||||
@ -215,7 +215,7 @@ function getWeekNote(dateStr, options = {}) {
|
|||||||
|
|
||||||
const dateObj = getStartOfTheWeek(dateUtils.parseLocalDate(dateStr), startOfTheWeek);
|
const dateObj = getStartOfTheWeek(dateUtils.parseLocalDate(dateStr), startOfTheWeek);
|
||||||
|
|
||||||
dateStr = dateUtils.utcDateStr(dateObj);
|
dateStr = dateUtils.utcDateTimeStr(dateObj);
|
||||||
|
|
||||||
return getDateNote(dateStr);
|
return getDateNote(dateStr);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ const dayjs = require('dayjs');
|
|||||||
const cls = require('./cls');
|
const cls = require('./cls');
|
||||||
|
|
||||||
function utcNowDateTime() {
|
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
|
// 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}`;
|
return num <= 9 ? `0${num}` : `${num}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function utcDateStr(date) {
|
function utcDateTimeStr(date) {
|
||||||
return date.toISOString().replace('T', ' ');
|
return date.toISOString().replace('T', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ module.exports = {
|
|||||||
utcNowDateTime,
|
utcNowDateTime,
|
||||||
localNowDateTime,
|
localNowDateTime,
|
||||||
localNowDate,
|
localNowDate,
|
||||||
utcDateStr,
|
utcDateTimeStr,
|
||||||
parseDate,
|
parseDate,
|
||||||
parseDateTime,
|
parseDateTime,
|
||||||
parseLocalDate,
|
parseLocalDate,
|
||||||
|
@ -466,7 +466,7 @@ function saveNoteRevision(note) {
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
const noteRevisionSnapshotTimeInterval = parseInt(optionService.getOption('noteRevisionSnapshotTimeInterval'));
|
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(
|
const existingNoteRevisionId = sql.getValue(
|
||||||
"SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND utcDateCreated >= ?", [note.noteId, revisionCutoff]);
|
"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 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);
|
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);
|
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);
|
eraseAttributes(attributeIdsToErase);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user