Skip to content
Browse files

Flesh out more ISO8601 parsing. Decide that leex/yec is the way to go

:)
  • Loading branch information...
1 parent 5cd6103 commit d67872149e1cfc03fb96903ea0fde6789d95cec2 @jlouis committed Oct 19, 2010
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/inet_time.erl
View
22 src/inet_time.erl
@@ -33,6 +33,28 @@ parse_iso_date_time(S) ->
{Time, []} = parse_iso_time(R2),
{iso_8601, Date, Time}.
+parse_interval_2(Limit, [D1, D2 | S])
+ when $0 =< D1, D1 =< $9, $0 =< D2, D2 =< $9 ->
+ N = list_to_integer([D1, D2]),
+ if
+ 0 =< N andalso N =< Limit ->
+ {N, S};
+ true ->
+ throw({no_parse, {invalid_integer_limit, N, Limit}})
+ end;
+parse_interval_2(Limit, _) ->
+ throw({no_parse, {expected_integer_limit, Limit}}).
+
+parse_time_hour(S) ->
+ parse_interval_2(24, S).
+
+parse_time_minute(S) ->
+ parse_interval_2(59, S).
+
+%% Here we just parse the minutes, we don't do anything specific with leap seconds, but accept any leap second value.
+parse_time_second(S) ->
+ parse_interval_2(60, S).
+
parse_iso_date(S) ->
{todo, S}.

0 comments on commit d678721

Please sign in to comment.
Something went wrong with that request. Please try again.