Skip to content
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

Open
choptastic opened this issue Jun 15, 2014 · 9 comments
Open

Get ISO8601 parsing working properly. #8

choptastic opened this issue Jun 15, 2014 · 9 comments

Comments

@choptastic
Copy link
Owner

No description provided.

@davidw
Copy link

davidw commented Aug 4, 2014

This looks like it might be useful: https://github.com/seansawyer/erlang_iso8601/blob/master/LICENSE

@choptastic
Copy link
Owner Author

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.

@davidw
Copy link

davidw commented Aug 5, 2014

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.

@choptastic
Copy link
Owner Author

Indeed. I'll be merging in your change CB for now, as it does the job.

Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm
On Aug 5, 2014 3:52 AM, "David N. Welton" [email protected] wrote:

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.


Reply to this email directly or view it on GitHub
#8 (comment).

@davidw
Copy link

davidw commented Aug 5, 2014

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...

@aramallo
Copy link
Contributor

aramallo commented Jul 9, 2015

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()).

@choptastic
Copy link
Owner Author

Awesome! Thanks!

@aramallo
Copy link
Contributor

aramallo commented Jul 9, 2015

Thanks to you! Awesome library :-)

On 9 Jul 2015, at 17:12, Jesse Gumm [email protected] wrote:

Awesome! Thanks!


Reply to this email directly or view it on GitHub #8 (comment).

@erszcz
Copy link

erszcz commented Aug 19, 2016

erlware/erlware_commons#109 partially fixes ISO 8601 parsing in ec_date. Partially, because arbitrary fractions of a second aren't accepted, only 3 or 6 places after the comma which correspond to milli- and microseconds only up to 6 places after the comma, which correspond to microsecond precision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants