mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
moved date functions to utils.js
This commit is contained in:
parent
d0cc5f4a5f
commit
16eb7a0639
@ -15,28 +15,6 @@ $(document).bind('keydown', 'alt+s', function() {
|
|||||||
$("input[name=search]").focus();
|
$("input[name=search]").focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
function getDateFromTS(timestamp) {
|
|
||||||
// Date accepts number of milliseconds since epoch so UTC timestamp works without any extra handling
|
|
||||||
// see https://stackoverflow.com/questions/4631928/convert-utc-epoch-to-local-date-with-javascript
|
|
||||||
const utcDate = new Date(timestamp * 1000);
|
|
||||||
|
|
||||||
const localDate = new Date(utcDate.getTime() - utcDate.getTimezoneOffset() * 60 * 1000);
|
|
||||||
|
|
||||||
return localDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(date) {
|
|
||||||
return (date.getHours() <= 9 ? "0" : "") + date.getHours() + ":" + (date.getMinutes() <= 9 ? "0" : "") + date.getMinutes();
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDate(date) {
|
|
||||||
return date.getDate() + ". " + (date.getMonth() + 1) + ". " + date.getFullYear();
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDateTime(date) {
|
|
||||||
return formatDate(date) + " " + formatTime(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
// hide (toggle) everything except for the note content for distraction free writing
|
// hide (toggle) everything except for the note content for distraction free writing
|
||||||
$(document).bind('keydown', 'alt+t', function() {
|
$(document).bind('keydown', 'alt+t', function() {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
@ -48,3 +48,25 @@ function uint8ToBase64(u8Arr) {
|
|||||||
function base64ToUint8Array(base64encoded) {
|
function base64ToUint8Array(base64encoded) {
|
||||||
return new Uint8Array(atob(base64encoded).split("").map(function(c) { return c.charCodeAt(0); }));
|
return new Uint8Array(atob(base64encoded).split("").map(function(c) { return c.charCodeAt(0); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDateFromTS(timestamp) {
|
||||||
|
// Date accepts number of milliseconds since epoch so UTC timestamp works without any extra handling
|
||||||
|
// see https://stackoverflow.com/questions/4631928/convert-utc-epoch-to-local-date-with-javascript
|
||||||
|
const utcDate = new Date(timestamp * 1000);
|
||||||
|
|
||||||
|
const localDate = new Date(utcDate.getTime() - utcDate.getTimezoneOffset() * 60 * 1000);
|
||||||
|
|
||||||
|
return localDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTime(date) {
|
||||||
|
return (date.getHours() <= 9 ? "0" : "") + date.getHours() + ":" + (date.getMinutes() <= 9 ? "0" : "") + date.getMinutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(date) {
|
||||||
|
return date.getDate() + ". " + (date.getMonth() + 1) + ". " + date.getFullYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateTime(date) {
|
||||||
|
return formatDate(date) + " " + formatTime(date);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user