public class Interval
extends com.google.gwt.core.client.JavaScriptObject
Intervals are created using D3.time()
factory methods, such as
Time.second()
.
Note: intervals created by the factory methods of D3().time() are intervals
based on local time. Use the utc()
method to convert the
interval to a UTC based interval.
Time intervals are irregular! For example, there are 60 seconds in a minute, but 24 hours in a day. Even more confusing, some days have 23 or 25 hours due to daylight saving time, and the standard Gregorian calendar uses months of differing lengths. And then there are leap years and leap seconds!
To simplify manipulation of and iteration over time intervals, D3 provides a handful of time utilities in addition to the time scale and format.
The utilities support both local time and UTC time. Local time is determined by the browser's JavaScript runtime; arbitrary time zone support would be nice, but requires access to the Olson zoneinfo files.
Modifier | Constructor and Description |
---|---|
protected |
Interval() |
Modifier and Type | Method and Description |
---|---|
Date |
apply(Date date)
Alias for
floor(Date) . |
double |
apply(double date)
Alias for
floor(double) . |
com.google.gwt.core.client.JsDate |
apply(com.google.gwt.core.client.JsDate date)
Alias for
floor(JsDate) . |
Date |
ceil(Date date)
Alias for
ceil(JsDate) for a Java date. |
double |
ceil(double date)
Alias for
round(JsDate) for a timestamp. |
com.google.gwt.core.client.JsDate |
ceil(com.google.gwt.core.client.JsDate date)
Returns the earliest time interval after the specified date.
|
Date |
floor(Date date)
Alias for
floor(JsDate) for a Java date. |
double |
floor(double date)
Alias for
floor(JsDate) for a timestamp. |
com.google.gwt.core.client.JsDate |
floor(com.google.gwt.core.client.JsDate date)
Return the latest time interval before or equal to the specified date.
|
Date |
offset(Date start,
int step)
Alias for
offset(JsDate, int) for java Date. |
double |
offset(double start,
int step)
Alias for
offset(JsDate, int) for double. |
com.google.gwt.core.client.JsDate |
offset(com.google.gwt.core.client.JsDate start,
int step)
Returns a new date equal to date plus step intervals.
|
Array<com.google.gwt.core.client.JsDate> |
range(Date start,
Date stop)
Alias for
range(JsDate start, JsDate stop) for java Date. |
Array<com.google.gwt.core.client.JsDate> |
range(Date start,
Date stop,
double step)
Alias for
range(JsDate start, JsDate stop, double step) for java Date. |
Array<com.google.gwt.core.client.JsDate> |
range(double start,
double stop)
Alias for
range(JsDate start, JsDate stop) for double. |
Array<com.google.gwt.core.client.JsDate> |
range(double start,
double stop,
double step)
Alias for
range(JsDate start, JsDate stop, double step) for double. |
Array<com.google.gwt.core.client.JsDate> |
range(com.google.gwt.core.client.JsDate start,
com.google.gwt.core.client.JsDate stop)
Returns every time interval after or equal to start and before stop.
|
Array<com.google.gwt.core.client.JsDate> |
range(com.google.gwt.core.client.JsDate start,
com.google.gwt.core.client.JsDate stop,
double step)
Returns every time interval after or equal to start and before stop.
|
Date |
round(Date date)
Alias for
round(JsDate) for a Java date. |
double |
round(double date)
Alias for
round(JsDate) for a timestamp. |
com.google.gwt.core.client.JsDate |
round(com.google.gwt.core.client.JsDate date)
Returns the closest time interval to the specified date.
|
Interval |
utc()
Returns a corresponding time interval in UTC rather than local time.
|
public final Interval utc()
public final com.google.gwt.core.client.JsDate apply(com.google.gwt.core.client.JsDate date)
floor(JsDate)
.date
- public final Date apply(Date date)
floor(Date)
.date
- public final double apply(double date)
floor(double)
.date
- public final com.google.gwt.core.client.JsDate floor(com.google.gwt.core.client.JsDate date)
date
- the date to convertpublic final Date floor(Date date)
floor(JsDate)
for a Java date.date
- the date to convertpublic final double floor(double date)
floor(JsDate)
for a timestamp.date
- public final com.google.gwt.core.client.JsDate round(com.google.gwt.core.client.JsDate date)
For example, d3.time().day().round(new Date()) returns midnight (12:00 AM) on the current day if it is on or before noon, and midnight of the following day if it is after noon.
date
- the date to convertpublic final Date round(Date date)
round(JsDate)
for a Java date.date
- the date to convertpublic final double round(double date)
round(JsDate)
for a timestamp.date
- public final com.google.gwt.core.client.JsDate ceil(com.google.gwt.core.client.JsDate date)
For example, d3.time.day.ceil(new Date()) returns midnight (12:00 AM) on the following day, in local time.
date
- the date to convertpublic final Date ceil(Date date)
ceil(JsDate)
for a Java date.date
- the date to convertpublic final double ceil(double date)
round(JsDate)
for a timestamp.date
- public final com.google.gwt.core.client.JsDate offset(com.google.gwt.core.client.JsDate start, int step)
If step is negative, then the returned date will be before the specified date; if step is zero, then a copy of the specified date is returned.
This method does not round the specified date to the interval. For example, if it is currently 5:34 PM, then d3.time.day.offset(new Date(), 1) returns 5:34 PM tomorrow (even if Daylight Savings Time changes!).
start
- the start datestep
- the number of intervals to add to the start datepublic final double offset(double start, int step)
offset(JsDate, int)
for double.start
- the start datestep
- the number of intervals to add to the start datepublic final Date offset(Date start, int step)
offset(JsDate, int)
for java Date.start
- the start datestep
- the number of intervals to add to the start datepublic final Array<com.google.gwt.core.client.JsDate> range(com.google.gwt.core.client.JsDate start, com.google.gwt.core.client.JsDate stop)
start
- the start timestop
- the stop timepublic final Array<com.google.gwt.core.client.JsDate> range(Date start, Date stop)
range(JsDate start, JsDate stop)
for java Date.
start
- the start timestop
- the stop timepublic final Array<com.google.gwt.core.client.JsDate> range(double start, double stop)
range(JsDate start, JsDate stop)
for double.
start
- the start timestop
- the stop timepublic final Array<com.google.gwt.core.client.JsDate> range(com.google.gwt.core.client.JsDate start, com.google.gwt.core.client.JsDate stop, double step)
start
- the start timestop
- the stop timepublic final Array<com.google.gwt.core.client.JsDate> range(Date start, Date stop, double step)
range(JsDate start, JsDate stop, double step)
for java Date.
start
- the start timestop
- the stop timepublic final Array<com.google.gwt.core.client.JsDate> range(double start, double stop, double step)
range(JsDate start, JsDate stop, double step)
for double.
start
- the start timestop
- the stop timeCopyright © 2015 gwt-d3. All rights reserved.