*
Number module

* *
@method [unit]()
@returns Number
@short Takes the number as a corresponding unit of time and converts to milliseconds.
@extra Method names can be both singular and plural.  Note that as "a month" is ambiguous as a unit of time, %months% will be equivalent to 30.4375 days, the average number in a month. Be careful using %months% if you need exact precision.

@set
millisecond
milliseconds
second
seconds
minute
minutes
hour
hours
day
days
week
weeks
month
months
year
years

@example

(5).milliseconds() -> 5
(10).hours()       -> 36000000
(1).day()          -> 86400000

**
@method [unit]Before([d], [locale] = currentLocale)
@returns Date
@short Returns a date that is <n> units before [d], where <n> is the number.
@extra [d] will accept a date object, timestamp, or text format. Note that "months" is ambiguous as a unit of time. If the target date falls on a day that does not exist (ie. August 31 -> February 31), the date will be shifted to the last day of the month. Be careful using %monthsBefore% if you need exact precision. See @date_format for more.

@set
millisecondBefore
millisecondsBefore
secondBefore
secondsBefore
minuteBefore
minutesBefore
hourBefore
hoursBefore
dayBefore
daysBefore
weekBefore
weeksBefore
monthBefore
monthsBefore
yearBefore
yearsBefore

@example

(5).daysBefore('tuesday')          -> 5 days before tuesday of this week
(1).yearBefore('January 23, 1997') -> January 23, 1996

**
@method [unit]Ago()
@returns Date
@short Returns a date that is <n> units ago.
@extra Note that "months" is ambiguous as a unit of time. If the target date falls on a day that does not exist (ie. August 31 -> February 31), the date will be shifted to the last day of the month. Be careful using %monthsAgo% if you need exact precision.

@set
millisecondAgo
millisecondsAgo
secondAgo
secondsAgo
minuteAgo
minutesAgo
hourAgo
hoursAgo
dayAgo
daysAgo
weekAgo
weeksAgo
monthAgo
monthsAgo
yearAgo
yearsAgo

@example

(5).weeksAgo() -> 5 weeks ago
(1).yearAgo()  -> January 23, 1996

**
@method [unit]After([d], [locale] = currentLocale)
@returns Date
@short Returns a date <n> units after [d], where <n> is the number.
@extra [d] will accept a date object, timestamp, or text format. Note that "months" is ambiguous as a unit of time. If the target date falls on a day that does not exist (ie. August 31 -> February 31), the date will be shifted to the last day of the month. Be careful using %monthsAfter% if you need exact precision. See @date_format for more.

@set
millisecondAfter
millisecondsAfter
secondAfter
secondsAfter
minuteAfter
minutesAfter
hourAfter
hoursAfter
dayAfter
daysAfter
weekAfter
weeksAfter
monthAfter
monthsAfter
yearAfter
yearsAfter

@example

(5).daysAfter('tuesday')          -> 5 days after tuesday of this week
(1).yearAfter('January 23, 1997') -> January 23, 1998

**
@method [unit]FromNow()
@returns Date
@short Returns a date <n> units from now.
@extra Note that "months" is ambiguous as a unit of time. If the target date falls on a day that does not exist (ie. August 31 -> February 31), the date will be shifted to the last day of the month. Be careful using %monthsFromNow% if you need exact precision.

@set
millisecondFromNow
millisecondsFromNow
secondFromNow
secondsFromNow
minuteFromNow
minutesFromNow
hourFromNow
hoursFromNow
dayFromNow
daysFromNow
weekFromNow
weeksFromNow
monthFromNow
monthsFromNow
yearFromNow
yearsFromNow

@example

(5).weeksFromNow() -> 5 weeks ago
(1).yearFromNow()  -> January 23, 1998

*
function buildNumberToDateAlias(u, multiplier) {
    var unit = u.unit, methods = {};
    function base() { return round(this * multiplier); }
    function after() { return createDate(arguments)[u.addMethod](this);  }
    function before() { return createDate(arguments)[u.addMethod](-this); }
    methods[unit] = base;
    methods[unit + 's'] = base;
    methods[unit + 'Before'] = before;
    methods[unit + 'sBefore'] = before;
    methods[unit + 'Ago'] = before;
    methods[unit + 'sAgo'] = before;
    methods[unit + 'After'] = after;
    methods[unit + 'sAfter'] = after;
    methods[unit + 'FromNow'] = after;
    methods[unit + 'sFromNow'] = after;
    number.extend(methods);
  }