Skip to content

Commit

Permalink
Merge pull request rawify#2 from psiphi75/master
Browse files Browse the repository at this point in the history
U-blox GPS receivers different format for time
  • Loading branch information
infusion authored Sep 14, 2016
2 parents 864a93c + c472f6a commit fd49d57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gps.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@
ret.setUTCHours(time.slice(0, 2));
ret.setUTCMinutes(time.slice(2, 4));
ret.setUTCSeconds(time.slice(4, 6));
ret.setUTCMilliseconds(parseFloat(time.slice(7)) || 0);

// Extract the milliseconds, since they can be not present, be 3 decimal place, or 2 decimal places, or other?
var msStr = time.slice(7);
var msExp = msStr.length;
var ms = 0;
if (msExp !== 0) {
ms = parseFloat(msStr) * Math.pow(10, 3 - msExp);
}
ret.setUTCMilliseconds(ms);

return ret;
}
Expand Down
15 changes: 15 additions & 0 deletions tests/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,21 @@ var tests = {
'time': new Date(today + 'T22:54:44.000Z'),
'type': 'GLL',
'valid': true
},
'$GPGGA,174815.40,4141.46474,N,00849.77225,W,1,08,1.24,11.8,M,50.5,M,,*76': {
'age': null,
'alt': 11.8,
'geoidal': 50.5,
'hdop': 1.24,
'quality': 'fix',
'satelites': 8,
'stationID': null,
'lat': 41.691079,
'lon': -8.8295375,
'time': new Date('2016-09-03T17:48:15.400Z'),
'raw': '$GPGGA,174815.40,4141.46474,N,00849.77225,W,1,08,1.24,11.8,M,50.5,M,,*76',
'type': 'GGA',
'valid': true,
}
};
var collect = {};
Expand Down

0 comments on commit fd49d57

Please sign in to comment.