@songsid/agend 2.1.0-beta.33 → 2.1.0-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-export.js +5 -2
- package/dist/chat-export.js.map +1 -1
- package/dist/cli.js +8 -3
- package/dist/cli.js.map +1 -1
- package/dist/daily-summary.js +7 -2
- package/dist/daily-summary.js.map +1 -1
- package/dist/fleet-manager.js +17 -2
- package/dist/fleet-manager.js.map +1 -1
- package/dist/tz-utils.d.ts +26 -0
- package/dist/tz-utils.js +46 -0
- package/dist/tz-utils.js.map +1 -0
- package/dist/ui/dashboard.html +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timezone helpers for event-db values.
|
|
3
|
+
*
|
|
4
|
+
* event-db (events/activity) stores timestamps as SQLite `datetime('now')` —
|
|
5
|
+
* "YYYY-MM-DD HH:MM:SS" in **UTC**, with no zone suffix. Storage stays UTC; these
|
|
6
|
+
* helpers convert only for DISPLAY (UTC→local) and QUERY BOUNDARIES (local→UTC),
|
|
7
|
+
* so user-facing times match the local convention used by chat-logs and fleet.log.
|
|
8
|
+
*
|
|
9
|
+
* TZ source matches the chat-log path: `process.env.TZ` override, else the
|
|
10
|
+
* system/Intl resolved zone.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveTz(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Convert a UTC event-db datetime string ("YYYY-MM-DD HH:MM:SS") to the same
|
|
15
|
+
* format in local `tz`. Unparseable input is returned unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export declare function utcDbToLocal(utcDbStr: string, tz?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Convert a local wall-clock string ("YYYY-MM-DD HH:MM:SS", interpreted in `tz`)
|
|
20
|
+
* to the UTC "YYYY-MM-DD HH:MM:SS" string matching event-db storage — for use as
|
|
21
|
+
* a range-query boundary. DST-safe via an offset round-trip. Unparseable input is
|
|
22
|
+
* returned unchanged.
|
|
23
|
+
*/
|
|
24
|
+
export declare function localWallToUtcDb(wall: string, tz?: string): string;
|
|
25
|
+
/** Local "today" date ("YYYY-MM-DD") in `tz`. */
|
|
26
|
+
export declare function localTodayDate(tz?: string): string;
|
package/dist/tz-utils.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timezone helpers for event-db values.
|
|
3
|
+
*
|
|
4
|
+
* event-db (events/activity) stores timestamps as SQLite `datetime('now')` —
|
|
5
|
+
* "YYYY-MM-DD HH:MM:SS" in **UTC**, with no zone suffix. Storage stays UTC; these
|
|
6
|
+
* helpers convert only for DISPLAY (UTC→local) and QUERY BOUNDARIES (local→UTC),
|
|
7
|
+
* so user-facing times match the local convention used by chat-logs and fleet.log.
|
|
8
|
+
*
|
|
9
|
+
* TZ source matches the chat-log path: `process.env.TZ` override, else the
|
|
10
|
+
* system/Intl resolved zone.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveTz() {
|
|
13
|
+
return process.env.TZ || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Convert a UTC event-db datetime string ("YYYY-MM-DD HH:MM:SS") to the same
|
|
17
|
+
* format in local `tz`. Unparseable input is returned unchanged.
|
|
18
|
+
*/
|
|
19
|
+
export function utcDbToLocal(utcDbStr, tz = resolveTz()) {
|
|
20
|
+
const d = new Date(utcDbStr.replace(" ", "T") + "Z");
|
|
21
|
+
if (Number.isNaN(d.getTime()))
|
|
22
|
+
return utcDbStr;
|
|
23
|
+
// sv-SE renders ISO-like "YYYY-MM-DD HH:MM:SS".
|
|
24
|
+
return d.toLocaleString("sv-SE", { timeZone: tz, hour12: false });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert a local wall-clock string ("YYYY-MM-DD HH:MM:SS", interpreted in `tz`)
|
|
28
|
+
* to the UTC "YYYY-MM-DD HH:MM:SS" string matching event-db storage — for use as
|
|
29
|
+
* a range-query boundary. DST-safe via an offset round-trip. Unparseable input is
|
|
30
|
+
* returned unchanged.
|
|
31
|
+
*/
|
|
32
|
+
export function localWallToUtcDb(wall, tz = resolveTz()) {
|
|
33
|
+
const asIfUtc = new Date(wall.replace(" ", "T") + "Z").getTime();
|
|
34
|
+
if (Number.isNaN(asIfUtc))
|
|
35
|
+
return wall;
|
|
36
|
+
// Render that instant in tz; the gap back to "as-if-UTC" is the zone offset at
|
|
37
|
+
// that instant (handles DST because it is sampled near the target instant).
|
|
38
|
+
const shownInTz = new Date(asIfUtc).toLocaleString("sv-SE", { timeZone: tz, hour12: false });
|
|
39
|
+
const offset = new Date(shownInTz.replace(" ", "T") + "Z").getTime() - asIfUtc;
|
|
40
|
+
return new Date(asIfUtc - offset).toISOString().slice(0, 19).replace("T", " ");
|
|
41
|
+
}
|
|
42
|
+
/** Local "today" date ("YYYY-MM-DD") in `tz`. */
|
|
43
|
+
export function localTodayDate(tz = resolveTz()) {
|
|
44
|
+
return new Date().toLocaleString("sv-SE", { timeZone: tz, hour12: false }).slice(0, 10);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=tz-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tz-utils.js","sourceRoot":"","sources":["../src/tz-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,EAAE,GAAG,SAAS,EAAE;IAC7D,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,KAAK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AAC;AAC1F,CAAC"}
|
package/dist/ui/dashboard.html
CHANGED
|
@@ -425,7 +425,7 @@ async function loadDetail() {
|
|
|
425
425
|
<div class="detail-row"><span class="detail-label">Rate 7d</span><span>${Math.round(rl7)}% <span class="progress-bar"><span class="progress-fill" style="width:${Math.min(rl7,100)}%;background:${rl7>90?'var(--error)':rl7>70?'var(--warn)':'var(--accent)'}"></span></span></span></div></div>`;
|
|
426
426
|
if (d.recent_activity?.length) {
|
|
427
427
|
h += `<div class="card"><h3>Recent Activity</h3>`;
|
|
428
|
-
for (const a of d.recent_activity) { const t=a.timestamp?a.timestamp.
|
|
428
|
+
for (const a of d.recent_activity) { const t=a.timestamp?new Date(a.timestamp.replace(" ","T")+"Z").toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""; h+=`<div class="activity-item"><span class="act-time">${t}</span><span class="act-event">${esc(a.event)}</span>${esc(a.summary||"")}</div>`; }
|
|
429
429
|
h += `</div>`;
|
|
430
430
|
}
|
|
431
431
|
el.innerHTML = h;
|