[erlang-questions] Date Conversion
Wes James
comptekki@REDACTED
Wed Nov 14 17:12:38 CET 2012
On Wed, Nov 14, 2012 at 2:26 AM, Lucky Khoza <mrkhoza@REDACTED> wrote:
> Hi Erlang Developers,
>
> How do i convert date string: "2012/02/15" to 2012/2/15, just to get rid
> of trailing Zero.
>
>
>
Some other examples:
-module(df).
-export([s/0]).
s() ->
Date = "2012/05/01",
DateS=string:tokens(Date,"/"),
io:format("~n~s~n", [rmz(DateS)]),
io:format("~n~s~n", [rmz2(DateS)]).
rmz([Year, Month, Day]) ->
Year++"/"++chopz(Month)++"/"++chopz(Day).
rmz2(Date) ->
io_lib:format("~n~s/~s/~s~n", Date).
chopz("0"++Num) ->
Num;
chopz(Num) ->
Num.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121114/b18f1e70/attachment.htm>
More information about the erlang-questions
mailing list