The goog.date Namespace

The goog.date.Date Class

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, {@see goog.date.DateTime}) 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. … more

.DateLike

@typedef
{(Date|goog.date.Date)}

The goog.date.DateRange Class

Constructs a date range. … more

The goog.date.DateTime Class

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. … more

The goog.date.Interval Class

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
 
… more

The goog.date.UtcDateTime Class

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. … more

.formatMonthAndYear(monthName, yearNum)

Formats a month/year string. Example: "January 2008"

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.

.fromIsoString(formatted)

Creates a DateTime from a datetime string expressed in ISO 8601 format.

formatted {string}
A date or datetime expressed in ISO 8601 format.
returns {goog.date.DateTime}
Parsed date or null if parse fails.

.getNumberOfDaysInMonth(year, month)

Returns the number of days for a given month.

year {number}
Year part of date.
month {number}
Month part of date.
returns {number}
The number of days for the given month.

.getWeekNumber(year, month, date, opt_weekDay, opt_firstDayOfWeek)

Static function for week number calculation. ISO 8601 implementation.

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

.isLeapYear(year)

Returns whether the given year is a leap year.

year {number}
Year part of date.
returns {boolean}
Whether the given year is a leap year.

.isLongIsoYear(year)

Returns whether the given year is a long ISO year. See {@link http://www.phys.uu.nl/~vgent/calendar/isocalendar_text3.htm}.

year {number}
Full year part of date.
returns {boolean}
Whether the given year is a long ISO year.

.isSameDay(date, opt_now)

Returns true if the 2 dates are in the same day.

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.

.isSameMonth(date, opt_now)

Returns true if the 2 dates are in the same month.

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.

.isSameYear(date, opt_now)

Returns true if the 2 dates are in the same year.

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.

The goog.date.month Enum

Constants for months. … more

The goog.date.relative Namespace

… more

.setIso8601DateTime(dateTime, formatted)

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.

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.

The goog.date.weekDay Enum

Constants for weekdays. … more