Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override the time format #31

Closed
lorenh opened this issue Mar 28, 2019 · 3 comments
Closed

Override the time format #31

lorenh opened this issue Mar 28, 2019 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@lorenh
Copy link
Contributor

lorenh commented Mar 28, 2019

I would like to override the time format written out in the GPX to optionally include fractional seconds.

NetTopologySuite.IO.GPX currently writes out this:

<trkpt lat="49.632506" lon="-94.067506">
  <time>2017-10-11T13:34:27Z</time>
</trkpt>

And we would like it to be this:

<trkpt lat="49.632506" lon="-94.067506">
  <time>2017-10-11T13:34:27.603Z</time>
</trkpt>

In Helpers.cs I see a hard-coded string format. Any way to override this?

        public static void WriteOptionalGpxElementValue(this XmlWriter writer, string localName, DateTime? valueUtc, TimeZoneInfo timeZoneInfo)
        {
            if (valueUtc.HasValue)
            {
                const string Format = "yyyy-MM-ddTHH:mm:ssK";
@airbreather airbreather added the enhancement New feature or request label Mar 28, 2019
@lorenh
Copy link
Contributor Author

lorenh commented Mar 28, 2019

I did a PR of one simple way you could do this:

#32

@airbreather airbreather added bug Something isn't working and removed enhancement New feature or request labels Apr 2, 2019
@airbreather airbreather self-assigned this Apr 2, 2019
@airbreather airbreather added this to the 0.5.0 milestone Apr 2, 2019
@airbreather
Copy link
Member

airbreather commented Apr 2, 2019

optionally include fractional seconds.

Starting in 0.5.0, timestamps are now always written out with fractional seconds, if present*. If there are cases where you don't want fractional seconds, then please do one of the following:

  • Use an input file that does not have any fractional seconds,
  • Round the timestamps in-memory (.WithTimestampUtc / .WithCreationTimeUtc)
  • Open a separate GitHub issue asking for the ability to opt-out. I'll gladly do this if this is something that's actually needed, but my guess is that 0.5.0 is good enough.

Thanks for the report!

*up the precision that DateTime stores internally, which is 100ns... this is not likely to change

@lorenh
Copy link
Contributor Author

lorenh commented Apr 2, 2019

Thanks for addressing so quickly. The best solution is one that "just works" for a majority of users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants