camstreamerlib
Version:
Helper library for CamStreamer ACAP applications.
30 lines (29 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeZoneDaemon = void 0;
const child_process_1 = require("child_process");
const util_1 = require("util");
const execPromise = (0, util_1.promisify)(child_process_1.exec);
class TimeZoneDaemon {
checkTimer;
constructor(checkInterval = 60000) {
this.checkTimer = setInterval(() => this.checkAndUpdateTimeZone(), checkInterval);
}
stop() {
clearInterval(this.checkTimer);
}
async checkAndUpdateTimeZone() {
try {
const { stdout } = await execPromise('timedatectl show -p Timezone --value');
const systemTimezone = stdout.toString().trim();
const nodeTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (systemTimezone !== nodeTimezone) {
process.env.TZ = systemTimezone;
}
}
catch (error) {
console.error('Error checking/updating timezone:', error);
}
}
}
exports.TimeZoneDaemon = TimeZoneDaemon;