From cf6d4cf9c0c38dd2ade3c578d4c32b1504b88de4 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 24 Oct 2024 18:28:40 +0100 Subject: [PATCH] timestamp is optional --- src/Track.elm | 4 ++-- tests/Fixtures.elm | 6 +++--- tests/TrackTest.elm | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Track.elm b/src/Track.elm index 5857671..51ae945 100644 --- a/src/Track.elm +++ b/src/Track.elm @@ -9,7 +9,7 @@ type alias Point = { lat : Float , lon : Float , ele : Maybe Float - , time : Time.Posix + , time : Maybe Time.Posix } type alias Track = List Point @@ -26,7 +26,7 @@ pointDecoder = XD.map4 Point (floatAttr "lat") (floatAttr "lon") (XD.maybe (path ["ele"] (single XD.float))) - (path ["time"] (single timeDecoder)) + (XD.maybe (path ["time"] (single timeDecoder))) gpxDecoder = diff --git a/tests/Fixtures.elm b/tests/Fixtures.elm index 6ce2d6c..b8d2750 100644 --- a/tests/Fixtures.elm +++ b/tests/Fixtures.elm @@ -65,7 +65,7 @@ xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/ """ threepoints_expected = - [ (Point 51.600643 -0.01856 (Just 64.8) (Time.millisToPosix 1729669252256)) - , (Point 51.600679 -0.018179 (Just 65.5) (Time.millisToPosix 1729669255259)) - , (Point 51.600697 -0.018064 (Just 66.2) (Time.millisToPosix 1729669256231)) + [ (Point 51.600643 -0.01856 (Just 64.8) (Just (Time.millisToPosix 1729669252256))) + , (Point 51.600679 -0.018179 (Just 65.5) (Just (Time.millisToPosix 1729669255259))) + , (Point 51.600697 -0.018064 (Just 66.2) (Just (Time.millisToPosix 1729669256231))) ] diff --git a/tests/TrackTest.elm b/tests/TrackTest.elm index dc86e67..490df4e 100644 --- a/tests/TrackTest.elm +++ b/tests/TrackTest.elm @@ -23,7 +23,7 @@ specs = Fixtures.threepoints in case Track.parse xml of - Ok (p::pts) -> Expect.equal p (Point 51.600643 -0.01856 Nothing (Time.millisToPosix 1729669252256)) + Ok (p::pts) -> Expect.equal p (Point 51.600643 -0.01856 Nothing (Just (Time.millisToPosix 1729669252256))) Ok _ -> Expect.fail "empty list" (Err f) -> Expect.fail f