Skip to content

Commit 19a34d5

Browse files
authored
Merge pull request #228 from ericpohl/tweak-gpstolocaldata
Look for valid GPS date/time when determining TaskDataMapper.GPSToLocalDelta
2 parents d3e0b35 + 148c850 commit 19a34d5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ISOv4Plugin/Mappers/TimeLogMapper.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,9 @@ protected IEnumerable<OperationData> ImportTimeLog(ISOTask loggedTask, ISOTimeLo
324324
//Set a UTC "delta" from the first record where possible. We set only one per data import.
325325
if (!TaskDataMapper.GPSToLocalDelta.HasValue)
326326
{
327-
var firstRecord = isoRecords.FirstOrDefault();
328-
if (firstRecord != null && firstRecord.GpsUtcDateTime.HasValue)
327+
//Find the first record with a valid GPS time and date. A GpsUtcDate of 0x0000 or 0xFFFF indicates an invalid date.
328+
var firstRecord = isoRecords.FirstOrDefault(r => r.GpsUtcDateTime.HasValue && r.GpsUtcDate != ushort.MaxValue && r.GpsUtcDate != 0);
329+
if (firstRecord != null)
329330
{
330331
//Local - UTC = Delta. This value will be rough based on the accuracy of the clock settings but will expose the ability to derive the UTC times from the exported local times.
331332
TaskDataMapper.GPSToLocalDelta = (firstRecord.TimeStart - firstRecord.GpsUtcDateTime.Value).TotalHours;

0 commit comments

Comments
 (0)