date.Date Extends
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.

Inheritance

Constructor

goog.date.Date(opt_yearopt_monthopt_date)

Parameters

opt_year : number | Object=
Four digit year or a date-like object. If not set, the created object will contain the date determined by goog.now().
opt_month : number=
Month, 0 = Jan, 11 = Dec.
opt_date : number=
Date of month, 1 - 31.

Instance Methods

Public Protected Private
Defined in goog.date.Date
add(interval)
Performs date calculation by adding the supplied interval to the date.
Arguments:
interval : goog.date.Interval
Date interval to add.
code »
buildDate_(fullYearmonthdate) !Date
new Date(y, m, d) treats years in the interval [0, 100) as two digit years, adding 1900 to them. This method ensures that calling the date constructor as a copy constructor returns a value that is equal to the passed in date value by explicitly setting the full year.
Arguments:
fullYear : number
The full year (including century).
month : number
The month, from 0-11.
date : number
The day of the month.
Returns: !Date  The constructed Date object.
code »
clone() !goog.date.Date
No description.
Returns: !goog.date.Date  A clone of the date object.
code »
equals(other) boolean
Tests whether given date is equal to this Date. Note: This ignores units more precise than days (hours and below) and also ignores timezone considerations.
Arguments:
other : goog.date.Date
The date to compare.
Returns: boolean  Whether the given date is equal to this one.
code »
getDate() number
No description.
Returns: number  The date of month.
code »
getDay() goog.date.weekDay
No description.
Returns: goog.date.weekDay  The day of week, US style. 0 = Sun, 6 = Sat.
code »
getDayOfYear() number
No description.
Returns: number  The day of year.
code »
getFirstDayOfWeek() number
No description.
Returns: number  The first day of the week. 0 = Mon, 6 = Sun.
code »
getFirstWeekCutOffDay() number
No description.
Returns: number  The cut off weekday used for week number calculations. 0 = Mon, 6 = Sun.
code »
getFullYear() number
No description.
Returns: number  The four digit year of date.
code »
getIsoWeekday() number
No description.
Returns: number  The day of week, ISO style. 0 = Mon, 6 = Sun.
code »
getMonth() goog.date.month
No description.
Returns: goog.date.month  The month of date, 0 = Jan, 11 = Dec.
code »
getNumberOfDaysInMonth() number
No description.
Returns: number  The number of days for the selected month.
code »
getTime() number
Returns the number of milliseconds since 1 January 1970 00:00:00.
Returns: number  The number of milliseconds since 1 January 1970 00:00:00.
code »
getTimezoneOffset() number
Returns timezone offset. The timezone offset is the delta in minutes between UTC and your local time. E.g., UTC+10 returns -600. Daylight savings time prevents this value from being constant.
Returns: number  The timezone offset.
code »
getTimezoneOffsetString() string
Returns timezone offset as a string. Returns offset in [+-]HH:mm format or Z for UTC.
Returns: string  The timezone offset as a string.
code »
getUTCDate() number
No description.
Returns: number  The date of month according to universal time.
code »
getUTCDay() goog.date.weekDay
No description.
Returns: goog.date.weekDay  The day of week according to universal time, US style. 0 = Sun, 1 = Mon, 6 = Sat.
code »
getUTCFullYear() number
No description.
Returns: number  The four digit year of date according to universal time.
code »
getUTCHours() number
No description.
Returns: number  The hours value according to universal time.
code »
getUTCIsoWeekday() number
No description.
Returns: number  The day of week according to universal time, ISO style. 0 = Mon, 6 = Sun.
code »
getUTCMinutes() number
No description.
Returns: number  The hours value according to universal time.
code »
getUTCMonth() goog.date.month
No description.
Returns: goog.date.month  The month of date according to universal time, 0 = Jan, 11 = Dec.
code »
getUTCWeekday() number
No description.
Returns: number  The day of week according to universal time and firstDayOfWeek setting.
code »
getWeekNumber() number
No description.
Returns: number  The week number.
code »
getWeekday() number
No description.
Returns: number  The day of week according to firstDayOfWeek setting.
code »
getYear() number
Alias for getFullYear.
Returns: number  The four digit year of date.
code »
maybeFixDst_(expected)
Fixes date to account for daylight savings time in browsers that fail to do so automatically.
Arguments:
expected : number
Expected date.
code »
set(date)
Sets the date.
Arguments:
date : goog.date.Date
Date object to set date from.
code »
setDate(date)
Sets the day part of the date.
Arguments:
date : number
The day part.
code »
setFirstDayOfWeek(day)
Sets the first day of week.
Arguments:
day : number
0 = Mon, 6 = Sun.
code »
setFirstWeekCutOffDay(day)
Sets cut off weekday used for week number calculations. 0 = Mon, 6 = Sun.
Arguments:
day : number
The cut off weekday.
code »
setFullYear(year)
Sets the year part of the date.
Arguments:
year : number
Four digit year.
code »
setMonth(month)
Sets the month part of the date. TODO(nnaze): Update type to goog.date.month.
Arguments:
month : number
The month, where 0 = Jan, 11 = Dec.
code »
setTime(ms)
Sets the value of the date object as expressed in the number of milliseconds since 1 January 1970 00:00:00.
Arguments:
ms : number
Number of milliseconds since 1 Jan 1970.
code »
setUTCDate(date)
Sets the day part of the date according to universal time.
Arguments:
date : number
The UTC date.
code »
setUTCFullYear(year)
Sets the year part of the date according to universal time.
Arguments:
year : number
Four digit year.
code »
setUTCMonth(month)
Sets the month part of the date according to universal time.
Arguments:
month : number
The month, where 0 = Jan, 11 = Dec.
code »
setYear(year)
Alias for setFullYear.
Arguments:
year : number
Four digit year.
code »
toIsoString(opt_verboseopt_tz) string
Returns ISO 8601 string representation of date.
Arguments:
opt_verbose : boolean=
Whether the verbose format should be used instead of the default compact one.
opt_tz : boolean=
Whether the timezone offset should be included in the string.
Returns: string  ISO 8601 string representation of date.
code »
toString() string
Overloaded toString method for object.
Returns: string  ISO 8601 string representation of date.
code »
toUTCIsoString(opt_verboseopt_tz) string
Returns ISO 8601 string representation of date according to universal time.
Arguments:
opt_verbose : boolean=
Whether the verbose format should be used instead of the default compact one.
opt_tz : boolean=
Whether the timezone offset should be included in the string.
Returns: string  ISO 8601 string representation of date according to universal time.
code »
valueOf() number
No description.
Returns: number  Value of wrapped date.
code »

Instance Properties

Defined in goog.date.Date
date :
No description.
Code »
firstDayOfWeek_ :
First day of week. 0 = Mon, 6 = Sun.
Code »
firstWeekCutOffDay_ :
The cut off weekday used for week number calculations. 0 = Mon, 6 = Sun.
Code »

Static Methods

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 »

Package date

Package Reference