date

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.DateRange
Constructs a date range.
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
goog.date.UtcDateTime
Class representing a date/time in GMT+0 time zone, without daylight saving. Defaults to current date and time if none is specified. The get... and the getUTC... methods are equivalent.

Public Protected Private

Enumerations

goog.date.month :
Constants for months.
Constants:
APR
No description.
AUG
No description.
DEC
No description.
FEB
No description.
JAN
No description.
JUL
No description.
JUN
No description.
MAR
No description.
MAY
No description.
NOV
No description.
OCT
No description.
SEP
No description.
Code »
goog.date.weekDay :
Constants for weekdays.
Constants:
FRI
No description.
MON
No description.
SAT
No description.
SUN
No description.
THU
No description.
TUE
No description.
WED
No description.
Code »

Global Functions

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.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 »

Global Properties

goog.date.DateLike :
No description.
Code »
goog.date.DateRangeTest :
No description.
Code »
goog.date.UtcDateTimeTest :
No description.
Code »
goog.date.duration :
No description.
Code »
goog.date.durationTest :
No description.
Code »
goog.date.relative :
No description.
Code »
goog.date.relativeTest :
No description.
Code »
goog.date.relativeWithPlurals :
No description.
Code »
goog.date.relativeWithPluralsTest :
No description.
Code »
goog.date.splitDateStringRegex_ :
Regular expression for splitting date parts from ISO 8601 styled string. Examples: '20060210' or '2005-02-22' or '20050222' or '2005-08' or '2005-W22' or '2005W22' or '2005-W22-4', etc. For explanation and more examples, see: http://en.wikipedia.org/wiki/ISO_8601
Code »
goog.date.splitDurationRegex_ :
Regular expression for splitting duration parts from ISO 8601 styled string. Example: '-P1Y2M3DT4H5M6.7S'
Code »
goog.date.splitTimeStringRegex_ :
Regular expression for splitting time parts from ISO 8601 styled string. Examples: '18:46:39.994' or '184639.994'
Code »
goog.date.splitTimezoneStringRegex_ :
Regular expression for splitting timezone parts from ISO 8601 styled string. Example: The part after the '+' in '18:46:39+07:00'. Or '09:30Z' (UTC).
Code »

Package date

Package Reference