Releases: d3/d3-time-format
v2.1.1
v2.1.0
- Add
%f
for microseconds. - Add
%Q
for milliseconds since UNIX epoch. Thanks, @krukon! - Add
%s
for seconds since UNIX epoch. Thanks, @krukon! - Add
%u
for ISO 8601 day of week as a decimal number [1,7]. Thanks, @BrianMitchL! - Add
%V
for ISO 8601 week of year as a decimal number [01, 53]. Thanks, @BrianMitchL!
v2.0.5
v2.0.4
v2.0.3
v2.0.2
v2.0.1
v2.0.0
v1.1.0
v1.0.0
- First stable release.
Changes since D3 3.x
Pursuant to the great namespace flattening, the format constructors have new names:
- d3.time.format ↦ d3.timeFormat
- d3.time.format.utc ↦ d3.utcFormat
- d3.time.format.iso ↦ d3.isoFormat
The format.parse method has also been removed in favor of separate d3.timeParse, d3.utcParse and d3.isoParse parser constructors. Thus, this code in 3.x:
var parseTime = d3.time.format("%c").parse;
Can be rewritten in 4.0 as:
var parseTime = d3.timeParse("%c");
The multi-scale time format d3.time.format.multi has been replaced by d3.scaleTime’s tick format. Time formats now coerce inputs to dates, and time parsers coerce inputs to strings. The %Z
directive now allows more flexible parsing of time zone offsets, such as -0700
, -07:00
, -07
, and Z
. The %p
directive is now parsed correctly when the locale’s period name is longer than two characters (e.g., “a.m.”).
The default U.S. English locale now uses 12-hour time and a more concise representation of the date. This aligns with local convention and is consistent with date.toLocaleString in Chrome, Firefox and Node:
var now = new Date;
d3.timeFormat("%c")(new Date); // "6/23/2016, 2:01:33 PM"
d3.timeFormat("%x")(new Date); // "6/23/2016"
d3.timeFormat("%X")(new Date); // "2:01:38 PM"
You can now set the default locale using d3.timeFormatDefaultLocale! The locales are published as JSON to NPM.
The performance of time formatting and parsing has been improved, and the UTC formatter and parser have a cleaner implementation (that avoids temporarily overriding the Date global).
See CHANGES for all D3 changes since 3.x.