ruudverheijden / node-p1-reader

Node.js package for reading and parsing data from the P1 port of a Dutch or Belgian Smart Meter.
MIT License
25 stars 25 forks source link

DST is ignored in parsing of timestamp #8

Open toorinl opened 6 years ago

toorinl commented 6 years ago

If a timestamp is in daylight saving time, but the process is not, then a difference of 1 hour is recorded. DST is indicated with an S and normal time with a W. Below the quote from the specs and below that a suggestion on how to solve the issue.

ASCII presentation of Time stamp with Year, Month, Day, Hour, Minute, Second, and an indication whether DST is active (X=S) or DST is not active (X=W).

var parsedTimestamp = new Date("20"+timestamp.substring(0, 2)+' '+ timestamp.substring(2, 4)+ ' ' + timestamp.substring(4, 6)+ ' ' + timestamp.substring(6, 8)+ ':' + timestamp.substring(8, 10)+':' + timestamp.substring(10, 12)+ (timestamp.substring(12, 13)=='W' ? ' +1':' +2'));