Skip to content

Commit

Permalink
Fix datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Mar 2, 2016
1 parent c48db41 commit e03999c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const getAvl08 = (raw) => {
},
charge: match[33] === '1'
},
datetime: moment(`${match[32]}0000`, 'YYYYMMDDHHmmssZZ').toDate(),
datetime: moment(`${match[32]}+00:00`, 'YYYYMMDDHHmmssZZ').toDate(),
voltage: {
battery: parseInt(match[34], 10) / 100,
inputCharge: parseInt(match[35], 10) / 100,
Expand Down Expand Up @@ -202,7 +202,7 @@ const getAvl201 = (raw) => {
},
charge: match[33] === '1'
},
datetime: moment(`${match[32]}0000`, 'YYYYMMDDHHmmssZZ').toDate(),
datetime: moment(`${match[32]}+00:00`, 'YYYYMMDDHHmmssZZ').toDate(),
voltage: {
battery: parseInt(match[34], 10) / 100,
inputCharge: parseInt(match[35], 10) / 100
Expand Down Expand Up @@ -593,7 +593,7 @@ const getCommandInfo = (data) => {
gsm: parseInt(match[7], 10),
battery: parseFloat(match[8]),
odometer: parseFloat(match[9]),
datetime: moment(`${match[10]}0000`, 'DD/MM/YY HH:mm:ssZZ').toDate()
datetime: moment(`${match[10]} +00:00`, 'DD/MM/YY HH:mm:ss ZZ').toDate()
};
};

Expand Down
6 changes: 3 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('tz-parzer', () => {
expect(data.status.output[3]).to.be.false;
expect(data.status.output[4]).to.be.false;
expect(data.status.charge).to.be.true;
expect(data.datetime).to.eql(new Date(2016, 1, 9, 19, 43, 26));
expect(data.datetime).to.eql(new Date('2016-02-09T19:43:26.000Z'));
expect(data.voltage.battery).to.eql(3.98);
expect(data.voltage.inputCharge).to.eql(11.88);
expect(data.voltage.ada).to.eql(0);
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('tz-parzer', () => {
expect(data.status.input[3]).to.be.false;
expect(data.status.output[1]).to.be.false;
expect(data.status.charge).to.be.true;
expect(data.datetime).to.eql(new Date(2016, 1, 9, 19, 43, 26));
expect(data.datetime).to.eql(new Date('2016-02-09T19:43:26.000Z'));
expect(data.voltage.battery).to.eql(3.98);
expect(data.voltage.inputCharge).to.eql(11.88);
expect(data.lac).to.eql(13011);
Expand All @@ -138,7 +138,7 @@ describe('tz-parzer', () => {
expect(data.gsm).to.eql(29);
expect(data.battery).to.eql(4.01);
expect(data.odometer).to.eql(0.1527);
expect(data.datetime).to.eql(new Date(2016, 1, 19, 15, 0, 17));
expect(data.datetime).to.eql(new Date('2016-02-19T15:00:17.000Z'));
});

it('should return TZ-COMMAND SetUserPassword data parsed', () => {
Expand Down

0 comments on commit e03999c

Please sign in to comment.