NaiveDateTime.from_erl/2
limits us to 6 digit
precision.
How may we handle higher precision?
Case in point: {{2017, 11, 30}, {18, 37, 26, 2690120}}
is pulled from a SQLServer datetime2(7)
field.
see this:
my code is:
defp to_date({year, month, day}), do: NaiveDateTime.from_erl!({{year, month, day}, {0, 0, 0}}, {0, 6}) |> NaiveDateTime.to_string()
defp to_date({{year, month, day}, {hour, min, sec, msec}}) when msec < 1000000,
do: NaiveDateTime.from_erl!({{year, month, day}, {hour, min, sec}}, {msec, 6}) |> NaiveDateTime.to_string()
defp to_date(x), do: x
I’m using msec < 1000000
to prevent errors, but i’m loosing higher precision time-stamps.
Any suggestions please.