Coder Social home page Coder Social logo

tempo's People

Contributors

efine avatar si14 avatar superbobry avatar tnt-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tempo's Issues

building on macosx fails: tempo.c built to priv/tempo_drv.so

Dear All

The title says it all. Here's the eunit output:

======================== EUnit ========================
undefined
*** test module not found ***
**tempo


=ERROR REPORT==== 11-Dec-2012::15:54:34 ===
The on_load function for module tempo returned {error,
                                                {load_failed,
                                                 "Failed to load NIF library: 'dlopen(/Users/ivan/local/erlang/tempo_git/priv/tempo.so, 2): image not found'"}}
=======================================================

Attempting to run tempo fails with the same error. A symlink from priv/tempo.so to priv/tempo_drv.so makes everything ok.

I wonder if this is something to do with the rebar port compiler and compiling on macosx. I'e had a quick scan through rebar and google but not turned up anything.

(Apart from that, tempo is a /very/ handy piece of code!)

Best wishes

Ivan

Time zone support is wrong.

According to ISO8601, the time zone is represented either by ±HH, or ±HHMM, or by a single letter 'Z' for UTC.

In the code a simple %z is used, which omits the '±' delimiter. This is wrong and has to be corrected.

convert_format(iso8601) -> <<"%Y-%m-%dT%H:%M:%S%z">>;

Properly handle failure in NIFs

The current implementation crashes with a badmatch if a NIF doesn't return {ok, ...}. A more user-friendly behaviour would be to bubble the error:

(tempo_dev@yooki)7> tempo:parse(rfc1123, {datetime, B}).
** exception error: no match of right hand side value {error,format_mismatch}
     in function  tempo:parse_datetime/2 (src/tempo.erl, line 115)

milliseconds in strptime and strftime

It is impossible to parse string with milliseconds.
For example:
(tempo_dev@garry-desktop)22> tempo:parse(iso8601, {datetime, <<"2012-06-16T08:25:34.123+01:00">>}).
** exception error: no match of right hand side value {error,format_mismatch}
in function tempo:parse_datetime/2 (src/tempo.erl, line 115)

Also, there is no way to set right format, because strptime and strftime do not support milliseconds.

Restrict supported date interval

It looks like strptime and strftime behaviour for dates before 1900 varies across platforms, so I think we should throw an error on such inputs.

(tempo_dev@yooki)13> tempo:parse(<<"%Y">>, {unix, <<"1505">>}).  %% OS X
{error,format_mismatch}

Tempo ignores UTC offset

strptime and strftime supports '%z' field descriptor, but:

tempo:strptime(<<"%z">>, <<"+03:00">>).
{ok, 0.0}

tempo:strptime(<<"%H:%M:%S%z">>, <<"11:22:33+03:00">>).
{ok,40953.0}
tempo:strptime(<<"%H:%M:%S">>, <<"11:22:33">>).
{ok,40953.0}

Is it possible to expose timezone/UTC offset data?

Не компилируется под gcc 4.8.2

При попытке откомпилировать c помощью rebar compile на Ubuntu Server 14.04 под Erlang 17.3 и установленном gcc 4.8.2 выдает след. ошибки:

"
.../deps/tempo/c_src/tempo.c:163:5: error: missing initializer for field ‘flags’ of ‘ErlNifFunc’ [-Werror=missing-field-initializers]
{"strptime", 2, tempo_strptime},
^
In file included from /opt/test/kf_portal/deps/tempo/c_src/tempo.c:3:0:
/usr/local/lib/erlang/erts-6.2/include/erl_nif.h:132:14: note: ‘flags’ declared here
unsigned flags;
^
.../deps/tempo/c_src/tempo.c:164:5: error: missing initializer for field ‘flags’ of ‘ErlNifFunc’ [-Werror=missing-field-initializers]
{"strftime", 2, tempo_strftime}
^
In file included from /opt/test/kf_portal/deps/tempo/c_src/tempo.c:3:0:
/usr/local/lib/erlang/erts-6.2/include/erl_nif.h:132:14: note: ‘flags’ declared here
unsigned flags;
^
.../deps/tempo/c_src/tempo.c: In function ‘nif_init’:
.../deps/tempo/c_src/tempo.c:168:1: error: missing initializer for field ‘options’ of ‘ErlNifEntry’ [-Werror=missing-field-initializers]
ERL_NIF_INIT(tempo, tempo_funcs, &load, &reload, &upgrade, &unload)
^
In file included from /opt/test/kf_portal/deps/tempo/c_src/tempo.c:3:0:
/usr/local/lib/erlang/erts-6.2/include/erl_nif.h:148:14: note: ‘options’ declared here
unsigned options;
^
cc1: all warnings being treated as errors
"

Решается заменой строки {port_env, [{"CFLAGS", "$CFLAGS -std=gnu99 -Wall -Wextra -Werror -pedantic"}]}.

на {port_env, [{"CFLAGS", "$CFLAGS -std=gnu99 -w -pedantic"}]}.
в rebar.config

Simplify interface

I think we should choose between /2 and /3 functions and remove parse_* and format_* from the export list -- there should be only one way of doing things.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.