-
Notifications
You must be signed in to change notification settings - Fork 103
Closed
Description
Node Version: 0.0.1-beta.14
Node BACstack Version: 18.9.0
- Bug Report
- Feature Request
- Question
Current Behaviour (Bug Report)
Hi,
by performing a readProperty to property 130 (event-time-stamps), the returned value is seen as "Invalid Date".
Steps to reproduce Issue (Bug Report)
const bacstack = require('bacstack');
const client = new bacstack()
client.readProperty('10.12.44.11', { type: 2, instance: 8194 }, 130, (err, value) => {
console.log(err)
console.log(JSON.stringify(value.values))
console.log(value.values)
})
returns :
[
{ type: 104, value: Invalid Date },
{ type: 104, value: Invalid Date },
{ type: 104, value: Invalid Date }
]
The cause from this can be found at asn1.js, line 1000.
The date variable has the following value : {"len":5,"value":{"len":4,"value":"2022-10-26T22:00:00.000Z"}}, and the time : {"len":5,"value":{"len":4,"value":"1901-02-01T15:26:22.600Z"}}
Suggested correction
The bug can be corrected, in changing for example :
new Date(...) into :
value: new Date(date.value.value.getFullYear(), date.value.value.getMonth() -1 , date.value.value.getDate(), time.value.value.getHours(), time.value.value.getMinutes(), time.value.value.getSeconds(), time.value.value.getMilliseconds())};
Then, the result of the above-mentioned command is :
[
{ type: 104, value: 2022-09-27T14:26:22.600Z },
{ type: 104, value: 1900-12-31T23:00:00.000Z },
{ type: 104, value: 2022-09-27T15:34:59.800Z }
]
There, the second item of the array is not completely correct (it should be unspecified), but it makes the job...
Thanks in advance,
Cédric
Metadata
Metadata
Assignees
Labels
No labels