Skip to content

Releases: d3/d3-time

v1.0.7

14 Jun 22:09
Compare
Choose a tag to compare

v1.0.6

10 Mar 17:46
Compare
Choose a tag to compare
  • Update dependencies.

v1.0.5

28 Feb 17:06
Compare
Choose a tag to compare
  • Update dependencies.

v1.0.4

22 Sep 16:43
Compare
Choose a tag to compare

v1.0.3

12 Sep 23:24
Compare
Choose a tag to compare
  • Update Rollup.

v1.0.2

02 Aug 21:29
Compare
Choose a tag to compare
  • Add module entry point to package.json.

v1.0.1

29 Jul 22:58
Compare
Choose a tag to compare
  • Edit the README.

v1.0.0

14 Jun 22:55
Compare
Choose a tag to compare
  • First stable release.

Changes since D3 3.x

Pursuant to the great namespace flattening, the local time intervals have been renamed:

The UTC time intervals have likewise been renamed:

The local time range aliases have been renamed:

The UTC time range aliases have been renamed:

The behavior of interval.range (and the convenience aliases such as d3.timeDays) has been changed when step is greater than one. Rather than filtering the returned dates using the field number, interval.range now behaves like d3.range: it simply skips, returning every _step_th date. For example, the following code in 3.x returns only odd days of the month:

d3.time.days(new Date(2016, 4, 28), new Date(2016, 5, 5), 2);
// [Sun May 29 2016 00:00:00 GMT-0700 (PDT),
//  Tue May 31 2016 00:00:00 GMT-0700 (PDT),
//  Wed Jun 01 2016 00:00:00 GMT-0700 (PDT),
//  Fri Jun 03 2016 00:00:00 GMT-0700 (PDT)]

Note the returned array of dates does not start on the start date because May 28 is even. Also note that May 31 and June 1 are one day apart, not two! The behavior of d3.timeDays in 4.0 is probably closer to what you expect:

d3.timeDays(new Date(2016, 4, 28), new Date(2016, 5, 5), 2);
// [Sat May 28 2016 00:00:00 GMT-0700 (PDT),
//  Mon May 30 2016 00:00:00 GMT-0700 (PDT),
//  Wed Jun 01 2016 00:00:00 GMT-0700 (PDT),
//  Fri Jun 03 2016 00:00:00 GMT-0700 (PDT)]

If you want a filtered view of a time interval (say to guarantee that two overlapping ranges are consistent, such as when generating time scale ticks), you can use the new interval.every method or its more general cousin interval.filter:

d3.timeDay.every(2).range(new Date(2016, 4, 28), new Date(2016, 5, 5));
// [Sun May 29 2016 00:00:00 GMT-0700 (PDT),
//  Tue May 31 2016 00:00:00 GMT-0700 (PDT),
//  Wed Jun 01 2016 00:00:00 GMT-0700 (PDT),
//  Fri Jun 03 2016 00:00:00 GMT-0700 (PDT)]

Time intervals now expose an interval.count method for counting the number of interval boundaries after a start date and before or equal to an end date. This replaces d3.time.dayOfYear and related methods in 3.x. For example, this code in 3.x:

var now = new Date;
d3.time.dayOfYear(now); // 165

Can be rewritten in 4.0 as:

var now = new Date;
d3.timeDay.count(d3.timeYear(now), now); // 165

Likewise, in place of 3.x’s d3.time.weekOfYear, in 4.0 you would say:

d3.timeWeek.count(d3.timeYear(now), now); // 24

The new interval.count is of course more general. For example, you can use it to compute hour-of-week for a heatmap:

d3.timeHour.count(d3.timeWeek(now), now); // 64

Here are all the equivalences from 3.x to 4.0:

Read more

v0.3.2

13 Jun 17:44
Compare
Choose a tag to compare

v0.3.1

08 Jun 21:31
Compare
Choose a tag to compare
  • Internal cleaning of exports.