Name: d3-quarterly
Owner: FT Interactive News
Description: Tiny library to parse quarterly date strings to timestamp ranges
Created: 2017-09-04 13:19:59.0
Updated: 2017-09-09 23:31:41.0
Pushed: 2017-09-05 11:43:45.0
Homepage: null
Size: 33
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
d3-quarterly
will parse a “quarter” string (e.g., “Q3 2017”) and return a date object,
indicating either the lower or upper bounds of a quarter.
$ npm install d3-quarterly
import quarterly from 'd3-quarterly'
s
('General use', t => {
t lower = quarterly('Q1 2017', false);
t upper = quarterly('Q1 2017', true);
(lower.toISOString(), '2017-01-01T00:00:00.000Z');
(upper.toISOString(), '2017-03-31T23:59:59.999Z');
quarterly(quarterString: string, returnBoundsEnd: boolean = false)
quarterString: string
A string in the format 'QN YY(YY)?' where “N” is an integer 1-4 (incl.) and “YY(YY)?” is either a 2- or 4-integer year value
returnBoundsEnd: boolean
By default returns the lower bounds (i.e., the start) of a quarter. Pass true
to return the upper bounds.