separated utils from room template

This commit is contained in:
2025-05-25 14:45:50 +02:00
parent e9fb1ec7d8
commit c244c3a98a
2 changed files with 19 additions and 7 deletions

15
static/js/utils.js Normal file
View File

@@ -0,0 +1,15 @@
// Utility functions for DocuPulse
/**
* Formats a Unix timestamp into a localized date and time string
* @param {number} ts - Unix timestamp in seconds
* @returns {string} Formatted date and time string
*/
function formatDate(ts) {
if (!ts) return '';
const d = new Date(ts * 1000);
return d.toLocaleDateString() + ' ' + d.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
}
// Export the functions
export { formatDate };