Skip to content

Commit

Permalink
local test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin A. Hoogheem committed Sep 30, 2023
1 parent 90b68f0 commit a346d45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Sources/FitDataProtocol/Types/FitTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ internal extension FitTime {

static func decode(data: Data, base: BaseTypeData, arch: Endian, isLocal: Bool = false) -> FitTime? {
if let value = base.type.decode(type: UInt32.self, data: data, resolution: base.resolution, arch: arch) {
return FitTime(time: value, isLocal: isLocal)
// if date_time is < 0x10000000 then it is system time (seconds from device power on)
if value < 0x10000000 {
return FitTime(secondSincePowerUp: TimeInterval(value))
}

return FitTime(date: Date(timeInterval: TimeInterval(value), since: Date.antEPOCH), isLocal: isLocal)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions Tests/FitDataProtocolTests/FitMessageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FitMessageTests: XCTestCase {
}

extension FitMessageTests {

func testFileIdMessage() {
let time = Date()

Expand Down Expand Up @@ -160,7 +160,7 @@ extension FitMessageTests {
let index = MessageIndex(isSelected: true, value: 399)

let pos = Position(latitude: Measurement(value: 40, unit: UnitAngle.garminSemicircle),
longitude: Measurement(value: 80, unit: UnitAngle.garminSemicircle))
longitude: Measurement(value: 80, unit: UnitAngle.garminSemicircle))

let msg = CoursePointMessage(timeStamp: fTime,
messageIndex: index,
Expand Down

0 comments on commit a346d45

Please sign in to comment.