-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get ISO8601 parsing working properly. #8
Comments
This looks like it might be useful: https://github.com/seansawyer/erlang_iso8601/blob/master/LICENSE |
ec_date will, I believe, format and parse iso8601 properly already, but the key is ensuring it all plays nicely with qdate's timezone stuff. |
I need to get something figured out sooner rather than later, and would like to pick one of these and implement it. This 8601 code is nice because it does just the one thing. |
Indeed. I'll be merging in your change CB for now, as it does the job. Jesse Gumm
|
Well if there's some other code that's going to be used anyway, like qdate, perhaps this code could be stuffed in there (it's liberally licensed). Or maybe that can be the long term fix... |
This is what I am doing now :-) date_parser() ->
fun
(RawDate) when length(RawDate) == 20 ->
try
re:run(RawDate,"^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})Z",[{capture,all_but_first,list}])
of
nomatch -> undefined;
{match, [Y,M,D,H,I,S]} ->
Date = {list_to_integer(Y), list_to_integer(M), list_to_integer(D)},
Time = {list_to_integer(H), list_to_integer(I), list_to_integer(S)},
case calendar:valid_date(Date) of
true ->
{{Date, Time}, "UTC"};
false ->
undefined
end
catch
_:_ ->
undefined
end;
(_) ->
undefined
end.
qdate:register_parser(iso8601, date_parser()).
|
Awesome! Thanks! |
Thanks to you! Awesome library :-)
|
erlware/erlware_commons#109 partially fixes ISO 8601 parsing in |
No description provided.
The text was updated successfully, but these errors were encountered: