| 111618 | parcelHelpers.defineInteropFlag(exports); |
| 111619 | var t0 = new Date, t1 = new Date; |
| 111620 | function newInterval(floori, offseti, count, field) { |
| 111621 | function interval(date) { |
| 111622 | return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; |
| 111623 | } |
| 111624 | interval.floor = function(date) { |
| 111625 | return floori(date = new Date(+date)), date; |
| 111626 | }; |
| 111627 | interval.ceil = function(date) { |
| 111628 | return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; |
| 111629 | }; |
| 111630 | interval.round = function(date) { |
| 111631 | var d0 = interval(date), d1 = interval.ceil(date); |
| 111632 | return date - d0 < d1 - date ? d0 : d1; |
| 111633 | }; |
| 111634 | interval.offset = function(date, step) { |
| 111635 | return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; |
| 111636 | }; |
| 111637 | interval.range = function(start, stop, step) { |
| 111638 | var range = [], previous; |
| 111639 | start = interval.ceil(start); |
| 111640 | step = step == null ? 1 : Math.floor(step); |
| 111641 | if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date |
| 111642 | do range.push(previous = new Date(+start)), offseti(start, step), floori(start); |
| 111643 | while (previous < start && start < stop); |
| 111644 | return range; |
| 111645 | }; |
| 111646 | interval.filter = function(test) { |
| 111647 | return newInterval(function(date) { |
| 111648 | if (date >= date) while(floori(date), !test(date))date.setTime(date - 1); |
| 111649 | }, function(date, step) { |
| 111650 | if (date >= date) { |
| 111651 | if (step < 0) while(++step <= 0){ |
| 111652 | while(offseti(date, -1), !test(date)); // eslint-disable-line no-empty |
| 111653 | } |
| 111654 | else while(--step >= 0){ |
| 111655 | while(offseti(date, 1), !test(date)); // eslint-disable-line no-empty |
| 111656 | } |
| 111657 | } |
| 111658 | }); |
| 111659 | }; |
| 111660 | if (count) { |
| 111661 | interval.count = function(start, end) { |
| 111662 | t0.setTime(+start), t1.setTime(+end); |
| 111663 | floori(t0), floori(t1); |
| 111664 | return Math.floor(count(t0, t1)); |
| 111665 | }; |
| 111666 | interval.every = function(step) { |
| 111667 | step = Math.floor(step); |
| 111668 | return !isFinite(step) || !(step > 0) ? null : !(step > 1) ? interval : interval.filter(field ? function(d) { |
| 111669 | return field(d) % step === 0; |
| 111670 | } : function(d) { |
| 111671 | return interval.count(0, d) % step === 0; |
| 111672 | }); |
| 111673 | }; |
| 111674 | } |
| 111675 | return interval; |
| 111676 | } |
| 111677 | exports.default = newInterval; |