MooDate

Summary
Throws an error if value is not defined.
Throws an error if value is not the right type.
Shortcut to using Function.checkType with a boolean for type.
Same as new Date()
Same as Date.now
Shortcut to using Function.checkType with a number for type.
Shortcut to using Function.checkType with a number for type.
An array with each of the day names in order starting at Sunday.
An array with each of the day abbreviations in order starting at Sunday.
An array with each of the months names in order starting at January.
An array with each of the months abbreviations in order starting at January.
An array with each of the month lengths in order starting with January.
An array with each of the month lengths added together from the first month to the current in the array.
Same as Date.defaultLengths but modifies for a leap you if _isLeapYear is true.
Same as Date.defaultAggregateLengths but modifies for a leap you if _isLeapYear is true.
Checks if passed in year is a leap year.
Returns the year length, 366 if a leap year, else 365
Get the year”s week offset.
Convert a year date to a month date.
Created a copy of the current date.
Set the time to.
Same as to, but sets to the current time.
Same as to, but sets to the current time yesterday.
Same as to, but sets the the current time tomorrow.
Same as to, but sets the the current time this week.
Same as to, but sets the the current time last week.
Same as to, but sets the the current time next week.
Same as to, but sets the the current time this month.
Same as to, but sets the the current time last month.
Same as to, but sets the the current time next month.
Same as to, but sets the the current time this year.
Same as to, but sets the the current time last year.
Same as to, but sets the the current time next year.
Gets the name of the current day.
Gets the abbreviation of the current day.
Gets the name of the current month.
Gets the abbreviation of the current month.
Gets the date from the begining of the year.
Gets the day for the first day of the year.
Gets length of the current year.
Gets the date for yesterday.
Gets the date for tomorrow.
Gets the week of the year.
Gets a timestap for the begining of this week.
Gets the year date for the begining of this week.
Gets the date for last week.
Gets the date for next week.
Gets a timestamp for begining of this month.
Gets the year date at the begining of this month.
Gets the first week of this month.
Gets the day offset for the begining of this month.
Gets the length of this month.
Gets the length of the last month.
Gets the timestamp for last month.
Gets the timestamp for next month.
Gets the date for last year.
Gets the date for next year.
Sets the month and date to a year date.
Sets the month and date to this week.
Checks if this year is a leap year.
Check if a date object is before another date object
Check if a date object is after another date object
Check if an other date and time is the equal to this.
Check if an other date is the same as this.
Add an amount of time to a date.
Same as increment but decreases by the interval.
Clears hours, minutes, and seconds.

Files

MooDate.js

MooDateDate extention needed for MooMonth.

License

CC-GNU LGPL, http://creativecommons.org/licenses/LGPL/2.1/

MooDate Copyright

copyright © 2007 Roland Poulter, dnalor@moomonth.com

Function

Summary
Throws an error if value is not defined.
Throws an error if value is not the right type.
Shortcut to using Function.checkType with a boolean for type.

Functions

Function. checkValue

Function.checkValue = function(value,
kind)

Throws an error if value is not defined.

Arguments

valuevalue to be checked.
kindvalue name.

Function. checkType

Function.checkType = function(value,
type,
kind)

Throws an error if value is not the right type.

Arguments

valueValue to be checked.
typeType to check for.
kindValue”s name.

Function. checkBoolean

Function.checkBoolean = function(bool)

Shortcut to using Function.checkType with a boolean for type.  With a “boolean” kind.

Arguments

boolBoolean to be checked.

Date

Summary
Same as new Date()
Same as Date.now
Shortcut to using Function.checkType with a number for type.
Shortcut to using Function.checkType with a number for type.
An array with each of the day names in order starting at Sunday.
An array with each of the day abbreviations in order starting at Sunday.
An array with each of the months names in order starting at January.
An array with each of the months abbreviations in order starting at January.
An array with each of the month lengths in order starting with January.
An array with each of the month lengths added together from the first month to the current in the array.
Same as Date.defaultLengths but modifies for a leap you if _isLeapYear is true.
Same as Date.defaultAggregateLengths but modifies for a leap you if _isLeapYear is true.
Checks if passed in year is a leap year.
Returns the year length, 366 if a leap year, else 365
Get the year”s week offset.
Convert a year date to a month date.

Functions

Date.now

Date.now = function()

Same as new Date()

Returns

New date with the current time.

$today

$today = function()

Same as Date.now

Date. checkYear

Date.checkYear = function(year)

Shortcut to using Function.checkType with a number for type.  With a “year” kind.

Arguments

yearValue to be checked

Date. checkDate

Date.checkDate = function(date)

Shortcut to using Function.checkType with a number for type.  With a “date” kind.

Arguments

dateValue to be checked

Properties

Date. dayNames

An array with each of the day names in order starting at Sunday.

Date. dayAbbreviations

An array with each of the day abbreviations in order starting at Sunday.

Date. monthNames

An array with each of the months names in order starting at January.

Date. monthAbbreviations

An array with each of the months abbreviations in order starting at January.

Date. defaultLengths

An array with each of the month lengths in order starting with January.

Date. defaultAggregateLengths

An array with each of the month lengths added together from the first month to the current in the array.  Starts with January.

Functions

Date. getLengths

Date.getLengths = function(_isLeapYear)

Same as Date.defaultLengths but modifies for a leap you if _isLeapYear is true.

Arguments

booleanSet to true if leap year.

Returns

arrayDate.defaultAggregateLengths with modifications.

Date. getAggregateLengths

Date.getAggregateLengths = function(_isLeapYear)

Same as Date.defaultAggregateLengths but modifies for a leap you if _isLeapYear is true.

Arguments

booleanSet to true if leap year.

Returns

arrayDate.defaultAggregateLengths with modifications.

Date. isLeapYear

Date.isLeapYear = function(year)

Checks if passed in year is a leap year.

Arguments

numberYear to be checked.

Returns

booleanTrue if year is leap year, else false.

Date. yearLength

Date.yearLength = function(_isLeapYear)

Returns the year length, 366 if a leap year, else 365

Arguments

booleanSet to true if leap year.

Returns

numberYear length.

Date. yearStartDay

Date.yearStartDay = function(year)

Get the year”s week offset.

Arguments

numberYear.

Returns

numberYear”s week offset.

Date. yearDateToMonthDate

Date.yearDateToMonthDate = function(yearDate,
_isLeapYear)

Convert a year date to a month date.

Arguments

numberThe day number starting from the begining of the year.
booleanIs a leap year.

Returns

arrayMonth, and the day of the month.

Date. prototype Extention

Summary
Created a copy of the current date.
Set the time to.
Same as to, but sets to the current time.
Same as to, but sets to the current time yesterday.
Same as to, but sets the the current time tomorrow.
Same as to, but sets the the current time this week.
Same as to, but sets the the current time last week.
Same as to, but sets the the current time next week.
Same as to, but sets the the current time this month.
Same as to, but sets the the current time last month.
Same as to, but sets the the current time next month.
Same as to, but sets the the current time this year.
Same as to, but sets the the current time last year.
Same as to, but sets the the current time next year.
Gets the name of the current day.
Gets the abbreviation of the current day.
Gets the name of the current month.
Gets the abbreviation of the current month.
Gets the date from the begining of the year.
Gets the day for the first day of the year.
Gets length of the current year.
Gets the date for yesterday.
Gets the date for tomorrow.
Gets the week of the year.
Gets a timestap for the begining of this week.
Gets the year date for the begining of this week.
Gets the date for last week.
Gets the date for next week.
Gets a timestamp for begining of this month.
Gets the year date at the begining of this month.
Gets the first week of this month.
Gets the day offset for the begining of this month.
Gets the length of this month.
Gets the length of the last month.
Gets the timestamp for last month.
Gets the timestamp for next month.
Gets the date for last year.
Gets the date for next year.
Sets the month and date to a year date.
Sets the month and date to this week.
Checks if this year is a leap year.
Check if a date object is before another date object
Check if a date object is after another date object
Check if an other date and time is the equal to this.
Check if an other date is the same as this.
Add an amount of time to a date.
Same as increment but decreases by the interval.
Clears hours, minutes, and seconds.

Properties

copy

Created a copy of the current date.

Returns

dateA copy of the original date.

to

Set the time to.

Arguments

timestampTimestamp to be set to.

toNow

Same as to, but sets to the current time.

toYesterday

Same as to, but sets to the current time yesterday.

toTomorrow

Same as to, but sets the the current time tomorrow.

toThisWeek

Same as to, but sets the the current time this week.

toLastWeek

Same as to, but sets the the current time last week.

toNextWeek

Same as to, but sets the the current time next week.

toThisMonth

Same as to, but sets the the current time this month.

toLastMonth

Same as to, but sets the the current time last month.

toNextMonth

Same as to, but sets the the current time next month.

toThisYear

Same as to, but sets the the current time this year.

toThisYear

Same as to, but sets the the current time last year.

toThisYear

Same as to, but sets the the current time next year.

getDayName

Gets the name of the current day.

Returns

stringThe name of the day.

getDayAbbreviation

Gets the abbreviation of the current day.

Returns

stringThe abbreviation of the day.

getMonthName

Gets the name of the current month.

Returns

stringThe name of the month.

getMonthAbbreviation

Gets the abbreviation of the current month.

Returns

stringThe abbreviation of the month.

getYearDate

Gets the date from the begining of the year.

Returns

numberThe year date, between 0 and 366.

getYearStartDay

Gets the day for the first day of the year.

Returns

numberThe year start day, between 0 and 6.

getYearLength

Gets length of the current year.

Returns

numberThe year length, either 365 or 366.

getYesterday

Gets the date for yesterday.

Returns

numberYesterday.

getTomorrow

Gets the date for tomorrow.

Returns

numberTomorrow.

getWeek

Gets the week of the year.

Returns

numberWeek, between 0 and 52.

getWeekDate

Gets a timestap for the begining of this week.

Returns

timestampTime at the begining of this week.

getWeekYearDate

Gets the year date for the begining of this week.

Returns

numberYear date at the begining of this week, between 0 and 366.

getLastYear

Gets the date for last week.

Returns

numberLast week.

getNextWeek

Gets the date for next week.

Returns

numberNext week.

getMonthDate

Gets a timestamp for begining of this month.

Returns

timestampTime at the begining of this month.

getMonthYearDate

Gets the year date at the begining of this month.

Returns

numberYear date at the begining of this month.

getMonthWeek

Gets the first week of this month.

Returns

numberWeek.

getMonthDay

Gets the day offset for the begining of this month.

Returns

numberFirst day of the month, between 0 and 6.

getMonthEnd

Gets the length of this month.

Returns

numberMonth length.

getLastMonthEnd

Gets the length of the last month.

Returns

numberMonth length.

getLastMonth

Gets the timestamp for last month.

Returns

timestampLast month.

getNextMonth

Gets the timestamp for next month.

Returns

timestampLast month.

getLastYear

Gets the date for last year.

Returns

numberLast year.

getNextYear

Gets the date for next year.

Returns

numberNext year.

setYearDate

Sets the month and date to a year date.

Arguments

yearOptional, year.
yearDateNumber between 0, and 366

Returns

timestampNew time.

setWeek

Sets the month and date to this week.

Arguments

weekNumber between 0, and 52

Returns

timestampNew time.

Note

If the week is 52 it may go to week 0 depending on the current month.

isLeapYear

Checks if this year is a leap year.

Returns

booleantrue if this year is a leap year, else false.

isBefore

Check if a date object is before another date object

Arguments

dateDate to compare.

Returns

booleanTrue if before.

isAfter

Check if a date object is after another date object

Arguments

dateDate to compare.

Returns

booleanTrue if before.

equalTo

Check if an other date and time is the equal to this.

Arguments

dateDate to compare.

Returns

booleanTrue if equal.

equalDate

Check if an other date is the same as this.

Arguments

dateDate to compare.

Returns

booleanTrue if equal.

increment

Add an amount of time to a date.  Negative numbers can be passed to subtract time.

Arguments

stringIncrement interval.
numberAmount.

Returns

dateThis.

decrement

Same as increment but decreases by the interval.

clearTime

Clears hours, minutes, and seconds.

Returns

timestampNew date, without a time.
Function.checkValue = function(value,
kind)
Throws an error if value is not defined.
Function.checkType = function(value,
type,
kind)
Throws an error if value is not the right type.
Function.checkBoolean = function(bool)
Shortcut to using Function.checkType with a boolean for type.
Date.now = function()
Same as new Date()
$today = function()
Same as Date.now
Date.checkYear = function(year)
Shortcut to using Function.checkType with a number for type.
Date.checkDate = function(date)
Shortcut to using Function.checkType with a number for type.
Date.getLengths = function(_isLeapYear)
Same as Date.defaultLengths but modifies for a leap you if _isLeapYear is true.
An array with each of the month lengths in order starting with January.
Date.getAggregateLengths = function(_isLeapYear)
Same as Date.defaultAggregateLengths but modifies for a leap you if _isLeapYear is true.
An array with each of the month lengths added together from the first month to the current in the array.
Date.isLeapYear = function(year)
Checks if passed in year is a leap year.
Date.yearLength = function(_isLeapYear)
Returns the year length, 366 if a leap year, else 365
Date.yearStartDay = function(year)
Get the year”s week offset.
Date.yearDateToMonthDate = function(yearDate,
_isLeapYear)
Convert a year date to a month date.
Set the time to.
Add an amount of time to a date.