node-opcua-date-time
Advanced tools
Comparing version 2.1.0 to 2.1.3
@@ -28,2 +28,4 @@ export declare class DateWithPicoseconds extends Date { | ||
export declare function getCurrentClockWithJavascriptDate(): PreciseClock; | ||
export declare function installPeriodicClockAdjustmement(): void; | ||
export declare function uninstallPeriodicClockAdjustmement(): void; | ||
export declare function getCurrentClock(): PreciseClock; | ||
@@ -30,0 +32,0 @@ export declare function coerceClock(timestamp: any, picoseconds?: number): { |
@@ -134,4 +134,30 @@ "use strict"; | ||
exports.getCurrentClockWithJavascriptDate = getCurrentClockWithJavascriptDate; | ||
const origin = process.hrtime(); | ||
const refTime = Date.now(); | ||
let origin = process.hrtime(); | ||
let refTime = Date.now(); | ||
// update refTime now and then to make sure that we don't miss | ||
// any system time adjustment here such as a NTP clock event | ||
// see #651 | ||
let timerId; | ||
let timerInstallationCount = 0; | ||
const g_setInterval = global.setInterval; | ||
const g_clearInterval = global.clearInterval; | ||
function installPeriodicClockAdjustmement() { | ||
timerInstallationCount++; | ||
if (timerId) { | ||
return; | ||
} | ||
timerId = g_setInterval(() => { | ||
origin = process.hrtime(); | ||
refTime = Date.now(); | ||
}, 30000 /* every 30 seconds */); | ||
} | ||
exports.installPeriodicClockAdjustmement = installPeriodicClockAdjustmement; | ||
function uninstallPeriodicClockAdjustmement() { | ||
timerInstallationCount--; | ||
if (timerInstallationCount <= 0) { | ||
g_clearInterval(timerId); | ||
timerId = null; | ||
} | ||
} | ||
exports.uninstallPeriodicClockAdjustmement = uninstallPeriodicClockAdjustmement; | ||
const gClock = { | ||
@@ -138,0 +164,0 @@ tick: [0, 0], |
@@ -5,3 +5,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "2.1.0", | ||
"version": "2.1.3", | ||
"description": "pure nodejs OPCUA SDK - module -date-time", | ||
@@ -39,3 +39,3 @@ "scripts": { | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "ddce2b6e3e13371510e63d839c1a4c4ff0be2c15" | ||
"gitHead": "a47d959488b88d80c6d4d339d08c80ccc5490ffd" | ||
} |
@@ -154,4 +154,30 @@ /** | ||
const origin = process.hrtime(); | ||
const refTime = Date.now(); | ||
let origin = process.hrtime(); | ||
let refTime = Date.now(); | ||
// update refTime now and then to make sure that we don't miss | ||
// any system time adjustment here such as a NTP clock event | ||
// see #651 | ||
let timerId: NodeJS.Timeout | null; | ||
let timerInstallationCount = 0; | ||
const g_setInterval = global.setInterval; | ||
const g_clearInterval = global.clearInterval; | ||
export function installPeriodicClockAdjustmement() { | ||
timerInstallationCount++; | ||
if (timerId) { | ||
return; | ||
} | ||
timerId = g_setInterval(() => { | ||
origin = process.hrtime(); | ||
refTime = Date.now(); | ||
}, 30000 /* every 30 seconds */); | ||
} | ||
export function uninstallPeriodicClockAdjustmement() { | ||
timerInstallationCount--; | ||
if (timerInstallationCount <= 0) { | ||
g_clearInterval(timerId!); | ||
timerId = null; | ||
} | ||
} | ||
const gClock: PreciseClockEx = { | ||
@@ -164,2 +190,3 @@ tick: [0, 0], | ||
// make sure we get a pointer to the actual process.hrtime, | ||
@@ -166,0 +193,0 @@ // just in case it get overridden by some library (such as sinon) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34555
616