interledgerjs / btp-packet

Packet parser for Bilateral Transfer Protocol
1 stars 3 forks source link

Time is incorrectly encoded #41

Open uroshercog opened 5 years ago

uroshercog commented 5 years ago

Issue The time in the packets is not encoded in a way that the OER document under RFCs suggests: If the millisecond part is zero, it MUST be left out. Trailing zeros in the millisecond part MUST be left out. (OER Notes)

Code to reproduce

import dateFormat = require('dateformat');

const fn = d => Buffer.from(dateFormat(d, "UTC:yyyymmddHHMMss.l'Z'")).toString();

console.log(fn(new Date('2017-08-28T18:32:00.000Z')));
console.log(fn(new Date('2017-08-28T18:32:00.010Z')));
console.log(fn(new Date('2017-08-28T18:32:00.100Z')));

Results 20170828183200.000Z should be 20170828183200Z 20170828183200.010Z should be 20170828183200.01Z 20170828183200.100Z should be 20170828183200.1Z