JuliaTime / NanoDates.jl

Dates with nanosecond resolved days
MIT License
31 stars 3 forks source link

ISO 8601 timestamp fails to parse if missing precision #27

Closed tnagyzambo closed 1 year ago

tnagyzambo commented 1 year ago

This works: NanoDate("2022-12-21T10:14:38.012098970Z")

This errors: NanoDate("2022-12-21T10:14:38.01209897Z")

ArgumentError: invalid base 10 digit 'Z' in "97Z"

Stacktrace:
 [1] tryparse_internal(#unused#::Type{Int64}, s::String, startpos::Int64, endpos::Int64, base_::Int64, raise::Bool)
   @ Base ./parse.jl:137
 [2] parse(::Type{Int64}, s::String; base::Nothing)
   @ Base ./parse.jl:241
 [3] parse
   @ ./parse.jl:241 [inlined]
 [4] tosubsecs(ss::String)
   @ NanoDates ~/.julia/packages/NanoDates/pFWRe/src/strings.jl:238
 [5] NanoDate(str::String, df::Dates.DateFormat{Symbol("yyyy-mm-ddTHH:MM:SS.sssssssss"), Tuple{Dates.DatePart{'y'}, Dates.Delim{Char, 1}, Dates.DatePart{'m'}, Dates.Delim{Char, 1}, Dates.DatePart{'d'}, Dates.Delim{Char, 1}, Dates.DatePart{'H'}, Dates.Delim{Char, 1}, Dates.DatePart{'M'}, Dates.Delim{Char, 1}, Dates.DatePart{'S'}, Dates.Delim{Char, 1}, Dates.DatePart{'s'}}}; localtime::Bool)
   @ NanoDates ~/.julia/packages/NanoDates/pFWRe/src/strings.jl:274
 [6] NanoDate (repeats 2 times)
   @ ~/.julia/packages/NanoDates/pFWRe/src/strings.jl:261 [inlined]
 [7] top-level scope
   @ In[77]:7

Motivation: Exports from InlfuxDB drop trailing zeros.

JeffreySarnoff commented 1 year ago

Thank you.

JeffreySarnoff commented 1 year ago

fixed in main, pending merge