xue35 / TCX.jl

TCX parses TCX/XML sports file.
MIT License
1 stars 2 forks source link

DateTime Trailing 'Z' Problem #19

Closed brotherjack closed 4 years ago

brotherjack commented 4 years ago

Hello! I have run into a problem when running the TCX.prase_tcx_file method, namely this error:

ArgumentError: Unable to parse date time. Expected directive DatePart(Z) at char 20

The first date time in the file is "2020-05-20T21:57:17Z" and after some research I found this issue on the Julia repo that appears to be related to this.

I'm a bit new to Julia, and I'm still a bit shaky on how to compile code and run tests. In the REPL, I found that the following change to TCX.jl on line 59 appears to be a successful work around:

aid = try
        DateTime(xid,DictDateFormats[length(xid)])
    catch e
        if isa(e, ArgumentError)
            DateTime(xid[1:end-1], DictDateFormats[length(xid)][1:end-1])
        else
            throw(e)
        end 
    end

I've already cloned this repo, and can open a PR where this issue can be addressed. Does that sound good?

brotherjack commented 4 years ago

Oh boy do I feel silly! I just noticed what the problem actually is while setting up testing. The date time string I presented is 19 characters instead of 20 and 24, as the millisecond field is 2 characters instead of 3. There is a better solution to this problem, so I'll go ahead and close the PR and open a new one.