@@ -2264,6 +2265,14 @@ if (str_starts_with($route, '/api/')) {
${escapeHtml(m.body)}
-
${formatRelTime(m.created_at)}${m.mine && m.seen ? ' ' : ''}
+
${formatChatTime(m.created_at)}${m.mine && m.seen ? ' ' : ''}
`).join('');
@@ -750,6 +750,18 @@ $('chat-input')?.addEventListener('keydown', e => {
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); sendChatMessage(); }
});
+function formatChatTime(sqliteUtc) {
+ if (!sqliteUtc) return '';
+ const t = new Date(sqliteUtc.replace(' ', 'T') + 'Z');
+ if (isNaN(t.getTime())) return sqliteUtc;
+ const now = new Date();
+ const time = t.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
+ if (t.toDateString() === now.toDateString()) return time;
+ const yesterday = new Date(now); yesterday.setDate(yesterday.getDate() - 1);
+ if (t.toDateString() === yesterday.toDateString()) return 'yesterday ' + time;
+ return t.toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) + ' ' + time;
+}
+
function formatRelTime(sqliteUtc) {
if (!sqliteUtc) return '';
// Parse SQLite's "YYYY-MM-DD HH:MM:SS" as UTC by appending Z
diff --git a/src/Database.php b/src/Database.php
index 2b08764..f0cead3 100644
--- a/src/Database.php
+++ b/src/Database.php
@@ -152,6 +152,10 @@ class Database
self::$pdo->exec('CREATE INDEX IF NOT EXISTS idx_buckets_parent_id ON buckets(parent_id)');
}
+ if (!in_array('scratchpad', $colNames)) {
+ self::$pdo->exec("ALTER TABLE cards ADD COLUMN scratchpad TEXT DEFAULT NULL");
+ }
+
// Card edit history
self::$pdo->exec('
CREATE TABLE IF NOT EXISTS card_history (