danielwippermann / resol-vbus

A JavaScript library for processing RESOL VBus data
MIT License
67 stars 34 forks source link

system date - format #36

Closed brammh closed 4 years ago

brammh commented 4 years ago

Hi, Wonderfull work! Following your instructions I had the json-live-data-server example running with my deltasol in minutes. What I was not able to figure out is the format of the 'system date'. No clue how to parse this to a better readable format. See below my json. Any suggestions, I must be missing something obvious. Not a coding expert. thanks! { "id": "00_0010_1001_10_0100_000_4_0", "name": "System date", "rawValue": 676801591 },

danielwippermann commented 4 years ago

Hi @brammh,

normally that system date should be the amount of seconds passed since midnight of 2001-01-01. In JavaScript you can convert it similar to this:

const systemDate = 676801591;
const epochStart = Date.parse('2001-01-01T00:00:00Z');
const date = new Date(epochStart + systemDate * 1000);
console.log(date.toISOString());

That is basically what https://github.com/danielwippermann/resol-vbus/blob/6dc3bb308da809ef97fc624826355b716ade3715/src/specification.js#L1141 does as well.

But that outputs "2022-06-13T08:26:31.000Z" which is quite a bit off... And I cannot really tell why :)

brammh commented 4 years ago

That is perfect Daniel, very, very much appreciated! Apologies I missed it.