[erlang-questions] Date Conversion

Ian <>
Wed Nov 14 10:55:17 CET 2012


On 14/11/2012 09:26, Lucky Khoza wrote:
> Hi Erlang Developers,
>
> How do i convert date string: "2012/02/15" to 2012/2/15, just to get 
> rid of trailing Zero.
>
Lucky, this is at least the third trivial problem you asked in recent days.

Programming is the challenge of discovering how to solve a continuous 
series of new problems. If you don't think you would like to do that, 
find something else to do. If you do, go to it.

How I would approach it:

1) Define the problem ACCURATELY - its leading zeroes you want to remove.

2) Find three ways to solve the problem.
e.g.
   a) Split it up in to its parts, chop off leading zeros, reassemble.
   b) Its a date, so convert to binary date and convert back to 
formatted date using library functions.
   c) Parse it to remove any zero that occurs after a slash.

3) Choose the best, implement it and test it properly.

Regards

Ian

>
> Kindest Regards
> Lucky
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121114/ddd57041/attachment.html>


More information about the erlang-questions mailing list