- updated version to 1.0.23, enhance audio file handling, and improve UTC synchronization checks

This commit is contained in:
2026-01-06 12:28:08 +00:00
parent 79e759d811
commit ac9b3cc1ea
8 changed files with 73 additions and 18 deletions

View File

@@ -197,3 +197,21 @@ export const ValidateIPaddress = (value: string | undefined) => {
return "Invalid IP address format";
}
};
export function isUtcOutOfSync(
data: {
utctime: number;
localdate: string;
localtime: string;
},
maxDriftMs = 60_000
) {
const utc = new Date(data.utctime);
const [d, m, y] = data.localdate.split("/").map(Number);
const [hh, mm, ss] = data.localtime.split(":").map(Number);
// Construct local Date in devices local timezone
const local = new Date(y, m - 1, d, hh, mm, ss);
const driftMs = Math.abs(utc.getTime() - local.getTime() + utc.getTimezoneOffset() * 60_000);
return { driftMs, outOfSync: driftMs > maxDriftMs };
}