edate is an erlang date manipulation library
git clone git://github.com/dweldon/edate.git
cd edate && make
- today/0
- tomorrow/0
- yesterday/0
- shift/2
- shift/3
- beginning_of_month/1
- end_of_month/1
- date_to_string/1
- string_to_date/1
- day_of_week/1
returns today's date.
returns tomorrow's date.
returns yesterday's date.
returns a new date after shifting today's date by N periods. N is an integer,
Period is day | days | week | weeks | month | months | year | years
returns a new date after shifting StartDate by N periods. N is an integer,
Period is day | days | week | weeks | month | months | year | years
> edate:shift({2000,1,1}, -2, days).
{1999,12,30}
> edate:shift({2000,1,1}, 1, week).
{2000,1,8}
> edate:shift({2000,1,1}, 4, months).
{2000,5,1}
> edate:shift({2000,1,1}, 2, years).
{2002,1,1}
returns a new date representing the beginning of the month containing StartDate. > edate:beginning_of_month({2010,2,15}). {2010,2,1} > edate:beginning_of_month(edate:shift({2010,7,2}, -1, month)). {2010,6,1}
returns a new date representing the end of the month containing StartDate. > edate:end_of_month({2010,2,15}). {2010,2,28} > edate:end_of_month(edate:shift({2010,7,2}, -1, month)). {2010,6,30}
returns an ISO 8601 representation of Date. > edate:date_to_string({1976,3,18}). "1976-03-18"
returns a date representation of String. the following formats are valid (with or without zero-padding): YYYY-MM-DD, YYYY/MM/DD, MM-DD-YYYY, MM/DD/YYYY. > edate:string_to_date("1976-03-18"). {1976,3,18} > edate:string_to_date("3/18/1976"). {1976,3,18}
returns the day of the week as a string ("monday".."sunday"). > edate:day_of_week({2010,7,4}). "sunday"