antono/edate.js — Issue #3: months.ago
Author: coolaj86
Created: 2011-11-15 06:12:17+00:00
State: open

I'd like to add `months.ago`.

maybe it could be implemented like this

monthsGetter = ->
this.monthsGotten = this # the number, such as 2
this

if this.monthsGotten
date = new Date();
while this.monthsGotten
this.monthsGotten - 1;
month = date.getMonth()
if (month)
date.setMonth(date.getMonth() - 1)
else
date.setYear(date.getYear() -1)
date.setMonth(11)
date
else
new Date(Date.now() - this)

but I don't know if numbers can have members, so perhaps it would have to be implemented as `months_ago`

What do you think?