Walking Forum

Main Boards => General Walking Discussion => Topic started by: snaderson on 08:47:13, 02/07/19

Title: Garmin GPX files
Post by: snaderson 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  :)
Title: Re: Garmin GPX files
Post by: Patrick1 on 10:30:08, 02/07/19
This is due to the GPS date rollover, I suspect, which happened earlier this year. See here (https://www.theregister.co.uk/2019/02/12/current_gps_epoch_ends/), for example. Your fix looks a neat one, though, for devices who's firmware can't easily be updated.
Title: Re: Garmin GPX files
Post by: snaderson 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.