<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 14, 2012 at 2:26 AM, Lucky Khoza <span dir="ltr"><<a href="mailto:mrkhoza@gmail.com" target="_blank">mrkhoza@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hi Erlang Developers,<br><br>How do i convert date string: "2012/02/15" to 2012/2/15, just to get rid of trailing Zero.<br><br><br></blockquote><div><br></div><div><br></div><div>Some other examples:</div><div><br>
</div><div>-module(df).</div><div><br></div><div>-export([s/0]).</div><div><br></div><div>s() -></div><div> Date = "2012/05/01",</div><div> DateS=string:tokens(Date,"/"),</div><div> io:format("~n~s~n", [rmz(DateS)]),</div>
<div> io:format("~n~s~n", [rmz2(DateS)]).</div><div><br></div><div>rmz([Year, Month, Day]) -></div><div> Year++"/"++chopz(Month)++"/"++chopz(Day).</div><div><br></div><div>rmz2(Date) -></div>
<div> io_lib:format("~n~s/~s/~s~n", Date).</div><div><br></div><div>chopz("0"++Num) -></div><div> Num;</div><div>chopz(Num) -></div><div> Num. </div></div></div>