mirror of
https://github.com/TencentCloud/TencentDB-Agent-Memory
synced 2026-07-11 04:44:29 +00:00
feat: release v0.3.3 — Hermes adapter, context offload, core refactor
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Time utilities — all ISO 8601 timestamps use China Standard Time (UTC+08:00).
|
||||
*/
|
||||
|
||||
/** China timezone offset in minutes (+8 hours) */
|
||||
const CST_OFFSET_MINUTES = 8 * 60;
|
||||
|
||||
/**
|
||||
* Get the current time as an ISO 8601 string in China Standard Time (UTC+08:00).
|
||||
* Format: "2026-03-25T16:53:51.178+08:00"
|
||||
*/
|
||||
export function nowChinaISO(): string {
|
||||
return toChinaISO(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert any Date object to an ISO 8601 string in China Standard Time.
|
||||
* Format: "YYYY-MM-DDTHH:mm:ss.SSS+08:00"
|
||||
*/
|
||||
export function toChinaISO(date: Date): string {
|
||||
const utcMs = date.getTime();
|
||||
const cstMs = utcMs + CST_OFFSET_MINUTES * 60 * 1000;
|
||||
const cst = new Date(cstMs);
|
||||
const year = cst.getUTCFullYear();
|
||||
const month = String(cst.getUTCMonth() + 1).padStart(2, "0");
|
||||
const day = String(cst.getUTCDate()).padStart(2, "0");
|
||||
const hours = String(cst.getUTCHours()).padStart(2, "0");
|
||||
const minutes = String(cst.getUTCMinutes()).padStart(2, "0");
|
||||
const seconds = String(cst.getUTCSeconds()).padStart(2, "0");
|
||||
const ms = String(cst.getUTCMilliseconds()).padStart(3, "0");
|
||||
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${ms}+08:00`;
|
||||
}
|
||||
Reference in New Issue
Block a user