Parsing high precision timestamps?

I have a series of timestamps like 2020-01-01T12:34:56.789123Z. Trying to parse it with DateTime("2020-01-01T12:34:56.789123Z", dateformat"Y-m-dTH:M:S.ssssssZ") results in ERROR: LoadError: InexactError: convert(Dates.Decimal3, 789123).

I found TimesDates.jl, and I can work around this issue with the following: DateTime(TimeDate(timestr[1:end-1])), but that seems more brittle and also sort of silly. Is there a more canonical way to do this?

1 Like

Since Dates.DateTime is limited to millisecond precision anyways, you could just do DateTime(str[1:end-4]).

The problem is though that this also affects Dates.Time which should supports micro- and nanosecond precision and also downstream packages like AstroTime.jl which rely on the parser in Dates.

EDIT: I have posted a link to this thread in this issue https://github.com/JuliaLang/julia/issues/29339

1 Like

Oh, right :grimacing:

Thanks for the link to that issue, I’ll follow along there.

1 Like