Skip to content

fix(gpx): add timestamps to all trkpt elements for Strava/Garmin compatibility #126

@jasoneplumb

Description

@jasoneplumb

Problem

The GPX export omits <time> elements from <trkpt> nodes in some or all segments. Most apps (Strava, Garmin Connect, komoot) require <trkpt time="..."> on every point to:

  • Build elevation-over-time graphs
  • Calculate moving time vs. elapsed time
  • Merge splits correctly across pause segments

Without timestamps, imports either fail silently or strip the track to a static polyline with no time data.

Current State

Check src/recording.ts — the trailPoints array stores {latlng, t, speedMs, altM?} where t is a performance.now() timestamp. The GPX writer converts these but may not be attaching <time> to every point, or may be using relative timestamps instead of absolute ISO 8601.

Fix

Each <trkpt> must include:

<trkpt lat="..." lon="...">
  <ele>...</ele>
  <time>2026-04-18T14:23:01.000Z</time>
</trkpt>

t from performance.now() is milliseconds since page load — convert to absolute wall-clock time using Date.now() - performance.now() + t at the time of GPX export.

Files

  • src/recording.ts — GPX export function (search for gpx or trkpt)

Suggested Prompt

Fix GPX export to include ISO 8601 timestamps on every trkpt element (issue #NNN).
In src/recording.ts, find the GPX builder. Each trail point has a t field (performance.now() ms). Convert to absolute UTC using const epochOffset = Date.now() - performance.now() captured at export time, then new Date(epochOffset + point.t).toISOString(). Add a <time> child to every <trkpt>. Verify the output is valid GPX 1.1 (schema at topografix.com/GPX/1/1). Run npm run type-check && npm run lint before reporting done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions