Author Topic: Garmin GPX files  (Read 555 times)

snaderson

  • New Member
  • *
  • Posts: 17
Garmin GPX files
« on: 08:47:13, 02/07/19 »
My old Garmin eTrex Venture HC has started to record the dates incorrectly (it's partying like it's 1999). The only advice I can find involves 'deep' resets of the device which all sounds like a faff and about as likely to work as 'have you tried switching it off and on again?' Anyway, as my day job is doing this sort of thing, I've written a script to correct the dates (the times are ok), which I thought I would share in case it helps anyone else.
fixdate.ps1:Param(
    [Parameter(Mandatory=$true)]$GPXFile,
    [Parameter(Mandatory=$true)]$NewDate
)

Copy-Item "$GPXFile" "$GPXFile.bak" -Force
$xdoc = New-Object System.Xml.XmlDocument
$xdoc.Load($GPXFile)
$xdoc."gpx"."trk"."trkseg"."trkpt"|ForEach-Object {
    $_."time" = $_."time" -replace "^.{10}", "$NewDate"
}
$xdoc.Save($GPXFile)
To run it, start a Powershell window, cd to the directory where you've placed the script and call, e.g.:    .\fixdate.ps1 'C:\gpxfiles\broken.gpx' '2019-07-02'
My apologies for the quality of the code to anyone with better Powershell skills than me  :)

Patrick1

  • Jr. Member
  • **
  • Posts: 47
Re: Garmin GPX files
« Reply #1 on: 10:30:08, 02/07/19 »
This is due to the GPS date rollover, I suspect, which happened earlier this year. See here, for example. Your fix looks a neat one, though, for devices who's firmware can't easily be updated.

snaderson

  • New Member
  • *
  • Posts: 17
Re: Garmin GPX files
« Reply #2 on: 13:13:54, 02/07/19 »
Quote
devices who's firmware can't easily be updated
Indeed, when I've tried to update mine (on Windows 10), it's always failed.