edate

by David Weldon

Date manipulation in erlang isn’t very pleasant. The calendar module provides a lot of the raw tools but none of the convenience of something like the Date class in ruby, or the time calculation extensions in rails. I borrowed ideas from both and created edate. Check it out and let me know if I’m missing anything that would be helpful. Examples:

> Date = edate:string_to_date("7/15/2010").
{2010,7,15}
> edate:end_of_month(Date).
{2010,7,31}
> edate:shift(Date, 52, weeks).
{2011,7,14}
> edate:day_of_week(Date).
"thursday"

Advertisements