Check created time to be valid and discard milliseconds from date objects

This commit is contained in:
KAYLukas
2018-02-16 17:18:57 +01:00
parent 6ca8bc2180
commit 071fc35f38
10 changed files with 283 additions and 443 deletions

View File

@@ -100,17 +100,20 @@ export default {
readDate: function (bytes) {
const n = this.readNumber(bytes);
const d = new Date();
d.setTime(n * 1000);
const d = new Date(n * 1000);
return d;
},
writeDate: function (time) {
const numeric = Math.round(time.getTime() / 1000);
const numeric = Math.floor(time.getTime() / 1000);
return this.writeNumber(numeric, 4);
},
normalizeDate: function (time = Date.now()) {
return time === null ? time : new Date(Math.floor(+time / 1000) * 1000);
},
hexdump: function (str) {
const r = [];
const e = str.length;