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

Inheritance

Constructor

goog.date.Interval(opt_yearsopt_monthsopt_daysopt_hoursopt_minutesopt_seconds)

Parameters

opt_years : number | string=
Years or string representing date part.
opt_months : number=
Months or number of whatever date part specified by first parameter.
opt_days : number=
Days.
opt_hours : number=
Hours.
opt_minutes : number=
Minutes.
opt_seconds : number=
Seconds.

Instance Methods

Public Protected Private
add(interval)
Adds the Interval in the argument to this Interval field by field.
Arguments:
interval : goog.date.Interval
The Interval to add.
code »
clone() !goog.date.Interval
No description.
Returns: !goog.date.Interval  A clone of the interval object.
code »
equals(other) boolean
Tests whether the given interval is equal to this interval. Note, this is a simple field-by-field comparison, it doesn't account for comparisons like "12 months == 1 year".
Arguments:
other : goog.date.Interval
The interval to test.
Returns: boolean  Whether the intervals are equal.
code »
getInverse() !goog.date.Interval
No description.
Returns: !goog.date.Interval  Negative of this interval.
code »
getTotalSeconds() number
Gets the total number of seconds in the time interval. Assumes that months and years are empty.
Returns: number  Total number of seconds in the interval.
code »
isZero() boolean
No description.
Returns: boolean  Whether all fields of the interval are zero.
code »
times(n) !goog.date.Interval
Calculates n * (this interval) by memberwise multiplication.
Arguments:
n : number
An integer.
Returns: !goog.date.Interval  n * this.
code »
toIsoString(opt_verbose) ?string
Serializes goog.date.Interval into XML Schema duration (ISO 8601 extended).
Arguments:
opt_verbose : boolean=
Include zero fields in the duration string.
Returns: ?string  An XML schema duration in ISO 8601 extended format, or null if the interval contains both positive and negative fields.
code »

Instance Properties

days :
No description.
Code »
hours :
No description.
Code »
minutes :
No description.
Code »
months :
No description.
Code »
seconds :
No description.
Code »
years :
No description.
Code »

Static Methods

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 »

Static Properties

goog.date.Interval.DAYS :
Days constant for the date parts.
Code »
goog.date.Interval.HOURS :
Hours constant for the date parts.
Code »
goog.date.Interval.MINUTES :
Minutes constant for the date parts.
Code »
goog.date.Interval.MONTHS :
Months constant for the date parts.
Code »
goog.date.Interval.SECONDS :
Seconds constant for the date parts.
Code »
goog.date.Interval.YEARS :
Years constant for the date parts.
Code »

Package date

Package Reference