Skip to content

Commit

Permalink
Fix datetime parser
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Mar 1, 2016
1 parent fc73184 commit 3bf06c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const getMvt380 = (raw) => {
type: 'Point',
coordinates: [parseFloat(match[7]), parseFloat(match[6])]
},
datetime: moment(match[8], 'DDMMYYHHmmss').toDate(),
datetime: moment(`${match[8]}+00:00`, 'YYMMDDHHmmssZ').toDate(),
gpsSignal: match[9],
satellites: parseInt(match[10], 10),
gsmSignal: parseInt(match[11], 10),
Expand Down
7 changes: 4 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
'use strict';

import parser from '../lib';
import meitrack from '../lib';
import {expect} from 'chai';

describe('tz-parzer', () => {
describe('meitrack-parzer', () => {
describe('parse', () => {
it('should return the raw data parsed', () => {
const raw = new Buffer('$$A138,862170013556541,AAA,35,7.092076,79.960473,140412132808,A,10,9,57,275,1,14,5783799,7403612,413|1|F6E0|3933,0000,000B|0009||02D8|0122,*EE\r\n');
const data = parser.parse(raw);
const data = meitrack.parse(raw);
expect(data.raw).to.eql(raw.toString());
expect(data.type).to.eql('MVT380');
expect(data.imei).to.eql(862170013556541);
expect(data.command).to.eql('AAA');
expect(data.event).to.eql('timeIntervalTracking');
expect(data.loc.type).to.eql('Point');
expect(data.loc.coordinates).to.eql([79.960473, 7.092076]);
expect(data.datetime).to.eql(new Date('2014-04-12T13:28:08.000Z'));
expect(data.gpsSignal).to.eql('A');
expect(data.satellites).to.eql(10);
expect(data.gsmSignal).to.eql(9);
Expand Down

0 comments on commit 3bf06c8

Please sign in to comment.