Yes, I agree that your solution .getTime() seems to be the sole safe solution...
Thank's again for your reactivity.
There is no such thing as an uncoherent choice: But that's javascript standards... :)
E.setTimezone takes hours,
new Date().getTimezoneOffset() gives signed minutes,
new Date().getTime() gives ms,
*monthes are 0 based*
I had dreamed, apparently, to just add the new Date().getTimezone() minutes to the minute parameter of new Date(..., minute, ...) rather than convert everything to ms since 1970, just for simple straight readability.
To explain a bit more what makes me wondering so much: I get the gps time as 6 bytes in UTC time from ublox M8 binary protocol UBX-NAV-PVT or UBX-NVA-TIMEUTC for instance.
Here is an excerpt of my code, (this[289].buffer is Uint8Array containing exactly the ublox binary packet (absolutly the all of it, header and checksum included) and d the DataView on it.
The hidden magic trick here, is that if E.setTimezone(1) is system wide used, the UTC time will be wrong as it is so biaised and you can't see that reading the code: You have to be aware.
var posGps= {
...
get TIMEUTC() {
if (this[289]===undefined) return undefined;
let d=new DataView(this[289].buffer);
return {
iTOW: d.getUint32(6, true)/1000,
tAcc: d.getUint32(6+4, true)/1e9,
nano: d.getInt32(6+8, true)/1e9,
dateUTC : new Date(d.getUint16(12+6, true), d.getUint8(14+6, true)-1, d.getUint8(15+6, true), d.getUint8(16+6, true), d.getUint8(17+6, true), d.getUint8(18+6, true)),
valid: d.getUint8(6+19, true),
receivedAt : new Date(this.receivedAt[289]*1000)
};
},
...
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yes, I agree that your solution .getTime() seems to be the sole safe solution...
Thank's again for your reactivity.
There is no such thing as an uncoherent choice: But that's javascript standards... :)
I had dreamed, apparently, to just add the new Date().getTimezone() minutes to the minute parameter of new Date(..., minute, ...) rather than convert everything to ms since 1970, just for simple straight readability.
To explain a bit more what makes me wondering so much: I get the gps time as 6 bytes in UTC time from ublox M8 binary protocol UBX-NAV-PVT or UBX-NVA-TIMEUTC for instance.
Here is an excerpt of my code, (this[289].buffer is Uint8Array containing exactly the ublox binary packet (absolutly the all of it, header and checksum included) and d the DataView on it.
The hidden magic trick here, is that if E.setTimezone(1) is system wide used, the UTC time will be wrong as it is so biaised and you can't see that reading the code: You have to be aware.