Class jsDate
Defined in: jsdate.js.
Constructor Summary
Method Summary
getFullWeekOfYear()
Get the week number of the given year, starting with the first Sunday as the first week
getWeekOfYear()
Get the week number of the given year, starting with the first Monday as the first week
setFullYear(yearValue, monthValue, dayValue)
Sets the full year for a specified date according to local time.
setHours(hoursValue, minutesValue, secondsValue, msValue)
Sets the hours for a specified date according to local time.
strftime(date, formatString, syntax, locale)
daysInMonth(year, month)
Constructor Detail
new jsDate(arguments)
Object with extended date parsing and formatting capabilities. This library borrows many concepts and ideas from the Date Instance Methods by Ken Snyder along with some parts of Ken's actual code.
jsDate is fundamentally a new implementation, however. I takes a different approach by not extending the built-in Date Object, handling date parsing in a more robust manner, allowing for multiple formatting syntaxes and multiple, expandable localization.
Ken's origianl Date Instance Methods can be found at: http://kendsnyder.com/sandbox/date/
- Parameters:
- {String | Number | Array | Date Object | Options Object} arguments
- Optional arguments, either a parsable date/time string, a JavaScript timestamp, an array of numbers of form [year, month, day, hours, minutes, seconds, milliseconds], a Date object, or an options object of form {syntax: "perl", date:some Date} where all options are optional.
Method Detail
add(number, unit)
: jsDate
Add an arbitrary amount to the currently stored date
Parameters:
{Number} | number | |
{String} | unit |
Returns:
{jsDate} |
diff(dateObj, unit, allowDecimal)
: Number
Find the difference between this jsDate and another date.
Parameters:
{String| Number| Array| jsDate Object| Date Object} | dateObj | |
{String} | unit | |
{Boolean} | allowDecimal |
Returns:
{Number} | Number of units difference between dates. |
getCentury()
: Integer
Get the century (19 for 20th Century)
Returns:
{Integer} | Century (19 for 20th century). |
getDayOfWeek()
: Integer
Get the Day of week 1 (Monday) thru 7 (Sunday)
Returns:
{Integer} | Day of week 1 (Monday) thru 7 (Sunday) |
getFullWeekOfYear()
: Integer
Get the week number of the given year, starting with the first Sunday as the first week
Returns:
{Integer} | Week number (13 for the 13th full week of the year). |
getTimezoneAbbr()
: String
Get the timezone abbreviation
Returns:
{String} | Abbreviation for the timezone |
getTimezoneName()
: String
Get the browser-reported name for the current timezone (e.g. MDT, Mountain Daylight Time)
Returns:
{String} |
getWeekOfYear()
: Integer
Get the week number of the given year, starting with the first Monday as the first week
Returns:
{Integer} | Week number (13 for the 13th week of the year). |
next(unit)
: jsDate
Return a date one day ahead (or any other unit)
Parameters:
{String} | unit | Optional, year | month | day | week | hour | minute | second | millisecond |
Returns:
{jsDate} |
set(arguments)
Set the jsDate instance to a new date.
Parameters:
{String | Number | Array | Date Object | jsDate Object | Options Object} | arguments | Optional arguments, either a parsable date/time string, a JavaScript timestamp, an array of numbers of form [year, month, day, hours, minutes, seconds, milliseconds], a Date object, jsDate Object or an options object of form {syntax: "perl", date:some Date} where all options are optional. |
setDate(dayValue)
Sets the day of the month for a specified date according to local time.
Parameters:
{Integer} | dayValue | An integer from 1 to 31, representing the day of the month. |
setFullYear(yearValue, monthValue, dayValue)
Sets the full year for a specified date according to local time.
Parameters:
{Integer} | yearValue | The numeric value of the year, for example, 1995. |
{Integer} | monthValue | Optional, between 0 and 11 representing the months January through December. |
{Integer} | dayValue | Optional, between 1 and 31 representing the day of the month. If you specify the dayValue parameter, you must also specify the monthValue. |
setHours(hoursValue, minutesValue, secondsValue, msValue)
Sets the hours for a specified date according to local time.
Parameters:
{Integer} | hoursValue | An integer between 0 and 23, representing the hour. |
{Integer} | minutesValue | Optional, An integer between 0 and 59, representing the minutes. |
{Integer} | secondsValue | Optional, An integer between 0 and 59, representing the seconds. If you specify the secondsValue parameter, you must also specify the minutesValue. |
{Integer} | msValue | Optional, A number between 0 and 999, representing the milliseconds. If you specify the msValue parameter, you must also specify the minutesValue and secondsValue. |
strftime(formatString)
: String
Provide a formatted string representation of this date.
Parameters:
{String} | formatString | A format string. See: jsDate.formats. |
Returns:
{String} | Date String. |
toString()
: String
Return a String representation of this jsDate object.
Returns:
{String} | Date string. |
jsDate.strftime(date, formatString, syntax, locale)
: String
Parameters:
{String | Number | Array | jsDate Object | Date Object} | date | A parsable date string, JavaScript time stamp, Array of form [year, month, day, hours, minutes, seconds, milliseconds], jsDate Object or Date object. |
{String} | formatString | String with embedded date formatting codes. See: jsDate.formats. |
{String} | syntax | Optional syntax to use [default perl]. |
{String} | locale | Optional locale to use. |
Returns:
{String} | Formatted representation of the date. |