mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-16 12:30:49 +00:00
15 lines
764 B
TypeScript
15 lines
764 B
TypeScript
export function formatLocalIsoWithOffset(now: Date): string {
|
|
const year = now.getFullYear();
|
|
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
const day = String(now.getDate()).padStart(2, "0");
|
|
const h = String(now.getHours()).padStart(2, "0");
|
|
const m = String(now.getMinutes()).padStart(2, "0");
|
|
const s = String(now.getSeconds()).padStart(2, "0");
|
|
const ms = String(now.getMilliseconds()).padStart(3, "0");
|
|
const tzOffset = now.getTimezoneOffset();
|
|
const tzSign = tzOffset <= 0 ? "+" : "-";
|
|
const tzHours = String(Math.floor(Math.abs(tzOffset) / 60)).padStart(2, "0");
|
|
const tzMinutes = String(Math.abs(tzOffset) % 60).padStart(2, "0");
|
|
return `${year}-${month}-${day}T${h}:${m}:${s}.${ms}${tzSign}${tzHours}:${tzMinutes}`;
|
|
}
|