send along a local datetime so that the creation date is saved correctly including the timezone

This commit is contained in:
zadam 2020-05-29 20:27:17 +02:00
parent d3539ec9d7
commit 7a42d7e229
2 changed files with 14 additions and 2 deletions

1
.idea/vcs.xml generated
View File

@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -54,7 +54,7 @@ class TriliumServerFacade {
this.setTriliumSearch({ status: 'searching' });
const startingPort = await this.getStartingPort();
for (let testedPort = startingPort; testedPort < startingPort + 10; testedPort++) {
try {
console.debug('Trying port ' + testedPort);
@ -163,6 +163,7 @@ class TriliumServerFacade {
await this.waitForTriliumSearch();
fetchOptions.headers.Authorization = this.triliumSearch.token || "";
fetchOptions.headers['trilium-local-now-datetime'] = this.localNowDateTime();
const url = this.triliumSearch.url + "/api/clipper/" + path;
@ -184,6 +185,16 @@ class TriliumServerFacade {
return null;
}
}
localNowDateTime() {
const date = new Date();
const off = date.getTimezoneOffset();
const absoff = Math.abs(off);
return (new Date(date.getTime() - off * 60 * 1000).toISOString().substr(0,23).replace("T", " ") +
(off > 0 ? '-' : '+') +
(absoff / 60).toFixed(0).padStart(2,'0') + ':' +
(absoff % 60).toString().padStart(2,'0'));
}
}
window.triliumServerFacade = new TriliumServerFacade();
window.triliumServerFacade = new TriliumServerFacade();