date.js
No description.

File Location

/goog/date/date.js

Classes

goog.date.Date
Class representing a date. Defaults to current date if none is specified. Implements most methods of the native js Date object (except the time related ones, ) and can be used interchangeably with it just as if goog.date.Date was a synonym of Date. To make this more transparent, Closure APIs should accept goog.date.DateLike instead of the real Date object. To allow goog.date.Date objects to be passed as arguments to methods expecting Date objects this class is marked as extending the built in Date object even though that's not strictly true.
goog.date.DateTime
Class representing a date and time. Defaults to current date and time if none is specified. Implements most methods of the native js Date object and can be used interchangeably with it just as if goog.date.DateTime was a subclass of Date.
goog.date.Interval
Class representing a date/time interval. Used for date calculations.
new goog.date.Interval(0, 1) // One month
new goog.date.Interval(0, 0, 3, 1) // Three days and one hour
new goog.date.Interval(goog.date.Interval.DAYS, 1) // One day

Public Protected Private

Enumerations

Global Functions

goog.date.Date.compare(date1date2) number
Compares two dates. May be used as a sorting function.
Arguments:
date1 : !goog.date.DateLike
Date to compare.
date2 : !goog.date.DateLike
Date to compare.
Returns: number  Comparison result. 0 if dates are the same, less than 0 if date1 is earlier than date2, greater than 0 if date1 is later than date2.
code »
goog.date.formatMonthAndYear(monthNameyearNum) string
Formats a month/year string. Example: "January 2008"
Arguments:
monthName : string
The month name to use in the result.
yearNum : number
The numeric year to use in the result.
Returns: string  A formatted month/year string.
code »
goog.date.fromIsoString(formatted) goog.date.DateTime
Creates a DateTime from a datetime string expressed in ISO 8601 format.
Arguments:
formatted : string
A date or datetime expressed in ISO 8601 format.
Returns: goog.date.DateTime  Parsed date or null if parse fails.
code »
goog.date.Interval.fromIsoString(duration) goog.date.Interval
Parses an XML Schema duration (ISO 8601 extended).
Arguments:
duration : string
An XML schema duration in textual format. Recurring durations and weeks are not supported.
Returns: goog.date.Interval  The duration as a goog.date.Interval or null if the parse fails.
code »
goog.date.DateTime.fromRfc822String(formatted) goog.date.DateTime
Creates a DateTime from a datetime string expressed in RFC 822 format.
Arguments:
formatted : string
A date or datetime expressed in RFC 822 format.
Returns: goog.date.DateTime  Parsed date or null if parse fails.
code »
goog.date.DateTime.fromTimestamp(timestamp) !goog.date.DateTime
No description.
Arguments:
timestamp : number
Number of milliseconds since Epoch.
Returns: !goog.date.DateTime  No description.
code »
goog.date.getNumberOfDaysInMonth(yearmonth) number
Returns the number of days for a given month.
Arguments:
year : number
Year part of date.
month : number
Month part of date.
Returns: number  The number of days for the given month.
code »
goog.date.getWeekNumber(yearmonthdateopt_weekDayopt_firstDayOfWeek) number
Static function for week number calculation. ISO 8601 implementation.
Arguments:
year : number
Year part of date.
month : number
Month part of date (0-11).
date : number
Day part of date (1-31).
opt_weekDay : number=
Cut off weekday, defaults to Thursday.
opt_firstDayOfWeek : number=
First day of the week, defaults to Monday. Monday=0, Sunday=6.
Returns: number  The week number (1-53).
code »
goog.date.isLeapYear(year) boolean
Returns whether the given year is a leap year.
Arguments:
year : number
Year part of date.
Returns: boolean  Whether the given year is a leap year.
code »
goog.date.isLongIsoYear(year) boolean
Returns whether the given year is a long ISO year. See http://www.phys.uu.nl/~vgent/calendar/isocalendar_text3.htm.
Arguments:
year : number
Full year part of date.
Returns: boolean  Whether the given year is a long ISO year.
code »
goog.date.isSameDay(dateopt_now) boolean
Returns true if the 2 dates are in the same day.
Arguments:
date : goog.date.DateLike
The time to check.
opt_now : goog.date.DateLike=
The current time.
Returns: boolean  Whether the dates are on the same day.
code »
goog.date.isSameMonth(dateopt_now) boolean
Returns true if the 2 dates are in the same month.
Arguments:
date : goog.date.DateLike
The time to check.
opt_now : goog.date.DateLike=
The current time.
Returns: boolean  Whether the dates are in the same calendar month.
code »
goog.date.isSameYear(dateopt_now) boolean
Returns true if the 2 dates are in the same year.
Arguments:
date : goog.date.DateLike
The time to check.
opt_now : goog.date.DateLike=
The current time.
Returns: boolean  Whether the dates are in the same calendar year.
code »
goog.date.max(date1date2) !(T | S)
No description.
Arguments:
date1 : !T
A datelike object.
date2 : !S
Another datelike object.
Returns: !(T | S)  The later of them in time.
code »
goog.date.min(date1date2) !(T | S)
No description.
Arguments:
date1 : !T
A datelike object.
date2 : !S
Another datelike object.
Returns: !(T | S)  The earlier of them in time.
code »
goog.date.setDateFromIso8601Week_(dweekdayOfWeek)
Sets date fields based on an ISO 8601 week string. See http://en.wikipedia.org/wiki/ISO_week_date, "Relation with the Gregorian Calendar". The first week of a new ISO year is the week with the majority of its days in the new Gregorian year. I.e., ISO Week 1's Thursday is in that year. ISO weeks always start on Monday. So ISO Week 1 can contain a few days from the previous Gregorian year. And ISO weeks always end on Sunday, so the last ISO week (Week 52 or 53) can have a few days from the following Gregorian year. Example: '1997-W01' lasts from 1996-12-30 to 1997-01-05. January 1, 1997 is a Wednesday. So W01's Monday is Dec.30, 1996, and Sunday is January 5, 1997.
Arguments:
d : goog.date.DateTime
Object whose fields will be set.
week : number
ISO week number.
dayOfWeek : number
ISO day of week.
code »
goog.date.setIso8601DateOnly_(dformatted) boolean
Sets date fields based on an ISO 8601 format string.
Arguments:
d : !goog.date.DateTime
Object whose fields will be set.
formatted : string
A date expressed in ISO 8601 format.
Returns: boolean  Whether the parsing succeeded.
code »
goog.date.setIso8601DateTime(dateTimeformatted) boolean
Parses a datetime string expressed in ISO 8601 format. Overwrites the date and optionally the time part of the given object with the parsed values.
Arguments:
dateTime : !goog.date.DateTime
Object whose fields will be set.
formatted : string
A date or datetime expressed in ISO 8601 format.
Returns: boolean  Whether the parsing succeeded.
code »
goog.date.setIso8601TimeOnly_(dformatted) boolean
Sets time fields based on an ISO 8601 format string. Note: only time fields, not date fields.
Arguments:
d : !goog.date.DateTime
Object whose fields will be set.
formatted : string
A time expressed in ISO 8601 format.
Returns: boolean  Whether the parsing succeeded.
code »

Directory date

File Reference