Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
moved date functions to utils.js
azivner16eb7a063918
diff --git a/static/js/init.js b/static/js/init.jsindex 22bea3c75d..a08ba82ec6 100644--- a/static/js/init.js+++ b/static/js/init.js@@ -15,28 +15,6 @@ $(document).bind('keydown', 'alt+s', function() {$("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$(document).bind('keydown', 'alt+t', function() {const date = new Date();diff --git a/static/js/utils.js b/static/js/utils.jsindex 98140d8c59..6f7b02b464 100644--- a/static/js/utils.js+++ b/static/js/utils.js@@ -47,4 +47,26 @@ function uint8ToBase64(u8Arr) {function base64ToUint8Array(base64encoded) {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);}\ No newline at end of file