tkrajina / gpxgo

GPX library for golang
Apache License 2.0
88 stars 23 forks source link

About ToXml formatGPXTime #25

Open yangyang5214 opened 2 months ago

yangyang5214 commented 2 months ago

xml.go formatGPXTime method

const formattingTimelayout = "2006-01-02T15:04:05Z"

func formatGPXTime(time *time.Time) string {
    if time == nil {
        return ""
    }
    if time.Year() <= 1 {
        // Invalid date:
        return ""
    }
    return time.Format(formattingTimelayout)
}

maybe, use 2006-01-02T15:04:05.000Z not 2006-01-02T15:04:05Z


When I used the gpx file and tried to modify the speed to 100km/h, I encountered the problem of losing time accuracy.

eg : https://gpx.studio/ , This website can customize the speed .

tkrajina commented 1 month ago

Yes, good point.

Maybe something like this: https://github.com/tkrajina/gpxgo/commit/0a078e11c1cccf5466ffb087efcecff0246235c0#diff-467db995cc9329f7c2de3abceee7282826fdedf16a6c4efee5b2f3370065f8bdR145 (It will use the format with ms only if milliseconds are actually != 0).