Skip to content

Commit 5731c43

Browse files
committed
drop ms precision > 6
1 parent e8679d6 commit 5731c43

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/elixir/lib/calendar/iso.ex

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,13 +1993,9 @@ defmodule Calendar.ISO do
19931993
{[], 0, _} ->
19941994
:error
19951995

1996-
{microsecond, precision, rest} when precision in 1..6 ->
1997-
bs = length(microsecond)
1998-
scale = scale_factor(bs)
1996+
{microsecond, precision, rest} ->
1997+
scale = scale_factor(precision)
19991998
{{:erlang.list_to_integer(microsecond) * scale, precision}, rest}
2000-
2001-
{microsecond, _precision, rest} ->
2002-
{{:erlang.list_to_integer(Enum.take(microsecond, 6)), 6}, rest}
20031999
end
20042000
end
20052001

@@ -2011,6 +2007,9 @@ defmodule Calendar.ISO do
20112007
{{0, 0}, rest}
20122008
end
20132009

2010+
defp parse_microsecond(<<head, tail::binary>>, 6, acc) when head in ?0..?9,
2011+
do: parse_microsecond(tail, 6, acc)
2012+
20142013
defp parse_microsecond(<<head, tail::binary>>, precision, acc) when head in ?0..?9,
20152014
do: parse_microsecond(tail, precision + 1, [head | acc])
20162015

0 commit comments

Comments
 (0)