Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-opcua-date-time

Package Overview
Dependencies
Maintainers
0
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-date-time - npm Package Compare versions

Comparing version 2.133.0 to 2.134.0

12

dist/date_time.d.ts

@@ -1,5 +0,1 @@

export interface DateWithPicoseconds extends Date {
picoseconds: number;
high_low: [number, number];
}
export declare const offsetFactor1601: number[];

@@ -13,7 +9,7 @@ /**

*/
export declare function bn_dateToHundredNanoSecondFrom1601(date: Date, picoseconds: number): any;
export declare function bn_dateToHundredNanoSecondFrom1601(date: Date, picoseconds: number): number[];
export declare function bn_dateToHundredNanoSecondFrom1601Excess(date: Date, picoseconds: number): number;
export declare function bn_hundredNanoSecondFrom1601ToDate(high: number, low: number, picoseconds?: number, _value?: Date | null): DateWithPicoseconds;
export declare function bn_hundredNanoSecondFrom1601ToDate(high: number, low: number, picoseconds?: number, _value?: Date | null): [Date, number];
export interface PreciseClock {
timestamp: DateWithPicoseconds;
timestamp: Date;
picoseconds: number;

@@ -37,3 +33,3 @@ }

export declare function getCurrentClock(): PreciseClock;
export declare function coerceClock(timestamp: undefined | null | DateWithPicoseconds | Date, picoseconds?: number): PreciseClock;
export declare function coerceClock(timestamp: undefined | null | Date, picoseconds?: number): PreciseClock;
export declare function isMinDate(date?: Date | null): boolean;

@@ -40,0 +36,0 @@ export declare function getMinOPCUADate(): Date;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};

@@ -20,3 +40,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

*/
const long_1 = __importDefault(require("long"));
const long_1 = __importStar(require("long"));
const node_opcua_assert_1 = require("node-opcua-assert");

@@ -39,4 +59,4 @@ const node_opcua_utils_1 = require("node-opcua-utils");

const factor = exports.offsetFactor1601[1];
const offsetLong = long_1.default.fromNumber(offset, true);
const factorLong = long_1.default.fromNumber(factor, true);
const offsetLong = (0, long_1.fromNumber)(offset, true);
const factorLong = (0, long_1.fromNumber)(factor, true);
// Extracted from OpcUA Spec v1.02 : part 6:

@@ -84,5 +104,2 @@ //

function bn_dateToHundredNanoSecondFrom1601(date, picoseconds) {
if (date.high_low) {
return date.high_low;
}
// note : The value returned by the getTime method is the number

@@ -96,5 +113,5 @@ // of milliseconds since 1 January 1970 00:00:00 UTC.

const a = tL.add(offsetLong).multiply(factorLong).add(excess100nanosecond);
date.high_low = [a.getHighBits(), a.getLowBits()];
date.picoseconds = excess100nanosecond * 10000 + +picoseconds;
return date.high_low;
const high_low = [a.getHighBits(), a.getLowBits()];
const picoseconds2 = excess100nanosecond * 10000 + +picoseconds;
return high_low;
}

@@ -115,6 +132,5 @@ function bn_dateToHundredNanoSecondFrom1601Excess(date, picoseconds) {

const excess100nanoInPico = l.mod(10000).mul(100000).toNumber();
date.high_low = [high, low];
// picosecond will contains un-decoded 100 nanoseconds => 10 x 100 nanoseconds = 1 microsecond
date.picoseconds = excess100nanoInPico + (picoseconds || 0);
return date;
const picoseconds2 = excess100nanoInPico + (picoseconds || 0);
return [date, picoseconds2];
}

@@ -121,0 +137,0 @@ let lastNowDate;

@@ -0,3 +1,5 @@

/**
* @module node-opcua-date-time
*/
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
import { DateWithPicoseconds } from "./date_time";
export declare function isValidDateTime(value: any): value is Date;

@@ -18,4 +20,4 @@ export declare function randomDateTime(): Date;

*/
export declare function decodeDateTime(stream: BinaryStream, _value?: Date | null): DateWithPicoseconds;
export declare const decodeHighAccuracyDateTime: typeof decodeDateTime;
export declare function decodeDateTime(stream: BinaryStream, _value?: Date | null): Date;
export declare function decodeHighAccuracyDateTime(stream: BinaryStream, _value?: Date | null): [Date, number];
export declare function coerceDateTime(value: any): Date;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeHighAccuracyDateTime = void 0;
exports.isValidDateTime = isValidDateTime;

@@ -9,2 +8,3 @@ exports.randomDateTime = randomDateTime;

exports.decodeDateTime = decodeDateTime;
exports.decodeHighAccuracyDateTime = decodeHighAccuracyDateTime;
exports.coerceDateTime = coerceDateTime;

@@ -59,2 +59,5 @@ const date_time_1 = require("./date_time");

function decodeDateTime(stream, _value) {
return decodeHighAccuracyDateTime(stream, _value)[0];
}
function decodeHighAccuracyDateTime(stream, _value) {
const lo = stream.readInteger();

@@ -64,3 +67,2 @@ const hi = stream.readInteger();

}
exports.decodeHighAccuracyDateTime = decodeDateTime;
function coerceDateTime(value) {

@@ -67,0 +69,0 @@ if (!value) {

@@ -5,3 +5,3 @@ {

"types": "./dist/index.d.ts",
"version": "2.133.0",
"version": "2.134.0",
"description": "pure nodejs OPCUA SDK - module date-time",

@@ -14,3 +14,4 @@ "scripts": {

"dependencies": {
"long": "5.2.3",
"@types/long": "4.0.0",
"long": "4.0.0",
"node-opcua-assert": "2.120.0",

@@ -40,3 +41,3 @@ "node-opcua-binary-stream": "2.133.0",

"homepage": "http://node-opcua.github.io/",
"gitHead": "921bb04f2e7ce3109dd051ff27a2210edf700344",
"gitHead": "ccb34926a3c195f6a7e66fca58a2f101858e78be",
"files": [

@@ -43,0 +44,0 @@ "dist",

/**
* @module node-opcua-date-time
*/
import long from "long";
import long, { fromNumber } from "long";
import { assert } from "node-opcua-assert";
import { hrtime } from "node-opcua-utils";
export interface DateWithPicoseconds extends Date {
picoseconds: number;
high_low: [number, number];
}
export const offsetFactor1601 = (function offset_factor_1601() {

@@ -35,4 +30,4 @@ const utc1600 = new Date(Date.UTC(1601, 0, 1, 0, 0, 0));

const offsetLong = long.fromNumber(offset, true);
const factorLong = long.fromNumber(factor, true);
const offsetLong = fromNumber(offset, true);
const factorLong = fromNumber(factor, true);

@@ -81,5 +76,2 @@ // Extracted from OpcUA Spec v1.02 : part 6:

export function bn_dateToHundredNanoSecondFrom1601(date: Date, picoseconds: number) {
if ((date as any).high_low) {
return (date as any).high_low;
}
// note : The value returned by the getTime method is the number

@@ -95,5 +87,6 @@ // of milliseconds since 1 January 1970 00:00:00 UTC.

(date as any).high_low = [a.getHighBits(), a.getLowBits()];
(date as any).picoseconds = excess100nanosecond * 10000 + +picoseconds;
return (date as any).high_low;
const high_low = [a.getHighBits(), a.getLowBits()];
const picoseconds2 = excess100nanosecond * 10000 + +picoseconds;
return high_low;
}

@@ -111,3 +104,3 @@

_value: Date | null = null
): DateWithPicoseconds {
): [Date, number] {
assert(low !== undefined);

@@ -122,6 +115,5 @@ // value_64 / factor - offset = t

const excess100nanoInPico = l.mod(10000).mul(100000).toNumber();
(date as any).high_low = [high, low];
// picosecond will contains un-decoded 100 nanoseconds => 10 x 100 nanoseconds = 1 microsecond
(date as any).picoseconds = excess100nanoInPico + (picoseconds || 0);
return date as DateWithPicoseconds;
const picoseconds2 = excess100nanoInPico + (picoseconds || 0);
return [date, picoseconds2];
}

@@ -134,3 +126,3 @@

export interface PreciseClock {
timestamp: DateWithPicoseconds;
timestamp: Date;
picoseconds: number;

@@ -156,3 +148,3 @@ }

return {
timestamp: lastNowDate as DateWithPicoseconds,
timestamp: lastNowDate,

@@ -198,3 +190,3 @@ picoseconds: lastPicoseconds

tick: [0, 0],
timestamp: new Date() as DateWithPicoseconds,
timestamp: new Date(),

@@ -220,3 +212,3 @@ picoseconds: 0

gClock.timestamp = new Date(milliseconds) as DateWithPicoseconds;
gClock.timestamp = new Date(milliseconds);
gClock.picoseconds = picoseconds;

@@ -226,5 +218,5 @@ return gClock;

export function coerceClock(timestamp: undefined | null | DateWithPicoseconds | Date, picoseconds = 0): PreciseClock {
export function coerceClock(timestamp: undefined | null | Date, picoseconds = 0): PreciseClock {
if (timestamp) {
return { timestamp: timestamp as DateWithPicoseconds, picoseconds };
return { timestamp: timestamp as Date, picoseconds };
} else {

@@ -235,4 +227,2 @@ return getCurrentClock();

export function isMinDate(date?: Date | null): boolean {

@@ -248,3 +238,2 @@ if (typeof date === "number") {

// @deprecated use getMinOPCUADate() instead

@@ -251,0 +240,0 @@ export const minDate = new Date(Date.UTC(1601, 0, 1, 0, 0, 0));

/**
* @module node-opcua-date-time
*/
import { assert } from "node-opcua-assert";
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
import {
bn_dateToHundredNanoSecondFrom1601,
bn_hundredNanoSecondFrom1601ToDate,
DateWithPicoseconds,
getMinOPCUADate
} from "./date_time";
import { bn_dateToHundredNanoSecondFrom1601, bn_hundredNanoSecondFrom1601ToDate, getMinOPCUADate } from "./date_time";

@@ -65,3 +59,6 @@ // Date(year, month [, day, hours, minutes, seconds, ms])

*/
export function decodeDateTime(stream: BinaryStream, _value?: Date | null): DateWithPicoseconds {
export function decodeDateTime(stream: BinaryStream, _value?: Date | null): Date {
return decodeHighAccuracyDateTime(stream, _value)[0];
}
export function decodeHighAccuracyDateTime(stream: BinaryStream, _value?: Date | null): [Date, number] {
const lo = stream.readInteger();

@@ -71,3 +68,2 @@ const hi = stream.readInteger();

}
export const decodeHighAccuracyDateTime = decodeDateTime;

@@ -74,0 +70,0 @@ export function coerceDateTime(value: any): Date {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc