[erlang-questions] Date Conversion
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.
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.
> Kindest Regards
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions