RideBeeline / GpxKit

Swift GPX parser and writer
MIT License
13 stars 3 forks source link

Track with time that include timezone cannot be parsed #5

Open Applitom opened 6 years ago

Applitom commented 6 years ago

Hello, It is me again :) Thank you so much for this lovely open source!

I have an issue with parsing my GPX files that includes time zone in the track time. Example :

`

2395.221668
            <time>2018-02-02T10:47:30+01:00</time>
            <hdop>3</hdop>
            <vdop>0</vdop>
            <extensions>
                <gte:gps speed="9.740301" azimuth="-1.000000" />
            </extensions>
        </trkpt>`

When I try to parse this file, I get nil in the track points. After investigation I figured that the problem is with the dateFormat string in the DateFormatter+Extensions file. When I change it to be "yyyy-MM-dd'T'HH:mm:ssZ" instead of "yyyy-MM-dd'T'HH:mm:ss'Z'" it works perfectly.

Reference for this fix: https://stackoverflow.com/questions/41907419/ios-swift-3-convert-yyyy-mm-ddthhmmssz-format-string-to-date-object

I fixed it in my forked repo and i wonder if this is a valid fix, you can see it here: https://github.com/RideBeeline/GpxKit/compare/master...Applitom:master

Please let me know if you think i can submit PR for this fix or if you think of other solution.

Thanks!

marcbaldwin commented 6 years ago

Hello again!

You're right, the date format should indeed be yyyy-MM-dd'T'HH:mm:ssZ. The Z should not be escaped as it it's symbol representing the time zone.

So yes, please create a PR :)

Applitom commented 6 years ago

Cool! Thanks :)