node-opcua-date-time
Advanced tools
Comparing version 0.2.1 to 0.2.2
{ | ||
"name": "node-opcua-date-time", | ||
"main": "./src/date_time.js", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "pure nodejs OPCUA SDK - module -date-time", | ||
@@ -16,3 +16,3 @@ "scripts": { | ||
"node-opcua-benchmarker": "^0.2.0", | ||
"node-opcua-binary-stream": "^0.2.1", | ||
"node-opcua-binary-stream": "^0.2.2", | ||
"should": "13.2.1" | ||
@@ -19,0 +19,0 @@ }, |
@@ -73,6 +73,11 @@ "use strict"; | ||
// | ||
/** | ||
* | ||
* @param date {Date} | ||
* @returns {[high,low]} | ||
*/ | ||
function bn_dateToHundredNanoSecondFrom1601_fast(date) { | ||
assert(date instanceof Date); | ||
if (date.high_low) { | ||
return date.high_low; | ||
return date.high_low; | ||
} | ||
@@ -110,7 +115,3 @@ | ||
var high_low = [value_h, value_l]; | ||
Object.defineProperty(date, "high_low", { | ||
get: function () { | ||
return high_low; | ||
}, enumerable: false | ||
}); | ||
date.high_low = high_low; | ||
return high_low; | ||
@@ -133,8 +134,11 @@ } | ||
var date = new Date(value1); | ||
// enrich the date | ||
Object.defineProperty(date, "high_low", { | ||
get: function () { | ||
return [high, low]; | ||
}, enumerable: false | ||
}); | ||
date.high_low = [high,low]; | ||
//xxObject.defineProperty(date, "high_low", { | ||
//xx get: function () { | ||
//xx return [high, low]; | ||
//xx }, enumerable: false | ||
//xx}); | ||
return date; | ||
@@ -141,0 +145,0 @@ } |
@@ -37,2 +37,3 @@ "use strict"; | ||
}; | ||
const MAXUINT32 = 4294967295; // 2**32 - 1 | ||
exports.encodeDateTime = function (date, stream) { | ||
@@ -52,2 +53,11 @@ | ||
var lo = hl[1]; | ||
// make sure that date are not lower than expected limit | ||
if (hi<0 || lo<0) { | ||
hi=0;lo=0; | ||
} | ||
if (hi <0 || lo<0 || hi > MAXUINT32 || lo > MAXUINT32 ) { | ||
var hl = bn_dateToHundredNanoSecondFrom1601(date); | ||
throw new Error("INVALID " + hi + " "+lo + " "+date.toUTCString()); | ||
} | ||
stream.writeUInt32(lo); | ||
@@ -66,4 +76,7 @@ stream.writeUInt32(hi); | ||
function coerceDateTime(value) { | ||
if (value instanceof Date) { | ||
return value; | ||
} | ||
return new Date(value); | ||
} | ||
exports.coerceDateTime = coerceDateTime; |
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
23476
5
473