- // check for each format possibility and pick nearest
- long diff1 = Math.abs(SECS_SINCE_1970 - rawValue);
- long diff2 = Math.abs(MSECS_SINCE_1970 - rawValue);
- long diff3 = Math.abs(MSECS_SINCE_1990 - rawValue);
- long diff4 = Math.abs(SECS_SINCE_GARTRIP - rawValue);
-
- // Start off with "seconds since 1970" format
- long smallestDiff = diff1;
- _seconds = rawValue;
- // Now check millis since 1970
- if (diff2 < smallestDiff)
- {
- // milliseconds since 1970
- _seconds = rawValue / 1000L;
- smallestDiff = diff2;
- }
- // Now millis since 1990
- if (diff3 < smallestDiff)
- {
- // milliseconds since 1990
- _seconds = rawValue / 1000L + TWENTY_YEARS_IN_SECS;
- smallestDiff = diff3;
- }
- // Lastly, check garmin offset
- if (diff4 < smallestDiff)
- {
- // seconds since garmin offset
- _seconds = rawValue + GARTRIP_OFFSET;
- }