Comparing version 0.0.4 to 0.0.5
@@ -65,4 +65,4 @@ (function (global, factory) { | ||
date.setMilliseconds(0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 1e3); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 1e3); | ||
}, function(start, end) { | ||
@@ -76,4 +76,4 @@ return (end - start) / 1e3; | ||
date.setSeconds(0, 0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 6e4); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 6e4); | ||
}, function(start, end) { | ||
@@ -87,4 +87,4 @@ return (end - start) / 6e4; | ||
date.setMinutes(0, 0, 0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 36e5); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 36e5); | ||
}, function(start, end) { | ||
@@ -98,4 +98,4 @@ return (end - start) / 36e5; | ||
date.setHours(0, 0, 0, 0); | ||
}, function(date, offset) { | ||
date.setDate(date.getDate() + offset); | ||
}, function(date, step) { | ||
date.setDate(date.getDate() + step); | ||
}, function(start, end) { | ||
@@ -111,4 +111,4 @@ return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * 6e4) / 864e5; | ||
date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); | ||
}, function(date, offset) { | ||
date.setDate(date.getDate() + offset * 7); | ||
}, function(date, step) { | ||
date.setDate(date.getDate() + step * 7); | ||
}, function(start, end) { | ||
@@ -154,4 +154,4 @@ return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * 6e4) / 6048e5; | ||
date.setDate(1); | ||
}, function(date, offset) { | ||
date.setMonth(date.getMonth() + offset); | ||
}, function(date, step) { | ||
date.setMonth(date.getMonth() + step); | ||
}, function(start, end) { | ||
@@ -166,4 +166,4 @@ return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; | ||
date.setMonth(0, 1); | ||
}, function(date, offset) { | ||
date.setFullYear(date.getFullYear() + offset); | ||
}, function(date, step) { | ||
date.setFullYear(date.getFullYear() + step); | ||
}, function(start, end) { | ||
@@ -177,4 +177,4 @@ return end.getFullYear() - start.getFullYear(); | ||
date.setUTCMilliseconds(0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 1e3); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 1e3); | ||
}, function(start, end) { | ||
@@ -188,4 +188,4 @@ return (end - start) / 1e3; | ||
date.setUTCSeconds(0, 0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 6e4); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 6e4); | ||
}, function(start, end) { | ||
@@ -199,4 +199,4 @@ return (end - start) / 6e4; | ||
date.setUTCMinutes(0, 0, 0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 36e5); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 36e5); | ||
}, function(start, end) { | ||
@@ -210,4 +210,4 @@ return (end - start) / 36e5; | ||
date.setUTCHours(0, 0, 0, 0); | ||
}, function(date, offset) { | ||
date.setUTCDate(date.getUTCDate() + offset); | ||
}, function(date, step) { | ||
date.setUTCDate(date.getUTCDate() + step); | ||
}, function(start, end) { | ||
@@ -223,4 +223,4 @@ return (end - start) / 864e5; | ||
date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); | ||
}, function(date, offset) { | ||
date.setUTCDate(date.getUTCDate() + offset * 7); | ||
}, function(date, step) { | ||
date.setUTCDate(date.getUTCDate() + step * 7); | ||
}, function(start, end) { | ||
@@ -266,4 +266,4 @@ return (end - start) / 6048e5; | ||
date.setUTCDate(1); | ||
}, function(date, offset) { | ||
date.setUTCMonth(date.getUTCMonth() + offset); | ||
}, function(date, step) { | ||
date.setUTCMonth(date.getUTCMonth() + step); | ||
}, function(start, end) { | ||
@@ -278,4 +278,4 @@ return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; | ||
date.setUTCMonth(0, 1); | ||
}, function(date, offset) { | ||
date.setUTCFullYear(date.getUTCFullYear() + offset); | ||
}, function(date, step) { | ||
date.setUTCFullYear(date.getUTCFullYear() + step); | ||
}, function(start, end) { | ||
@@ -287,2 +287,3 @@ return end.getUTCFullYear() - start.getUTCFullYear(); | ||
exports.interval = newInterval; | ||
exports.second = second; | ||
@@ -289,0 +290,0 @@ exports.minute = minute; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.time={})}(this,function(e){"use strict";function t(e,n,u){function o(t){return e(t=new Date(+t)),t}return o.floor=o,o.round=function(t){var u=new Date(+t),r=new Date(t-1);return e(u),e(r),n(r,1),r-t>t-u?u:r},o.ceil=function(t){return e(t=new Date(t-1)),n(t,1),t},o.offset=function(e,t){return n(e=new Date(+e),null==t?1:Math.floor(t)),e},o.range=function(t,u,r){var a=[];if(t=new Date(t-1),u=new Date(+u),r=null==r?1:Math.floor(r),!(u>t&&r>0))return a;for(n(t,1),e(t),u>t&&a.push(new Date(+t));n(t,r),e(t),u>t;)a.push(new Date(+t));return a},o.filter=function(u){return t(function(t){for(;e(t),!u(t);)t.setTime(t-1)},function(e,t){for(;--t>=0;)for(;n(e,1),!u(e););})},u&&(o.count=function(t,n){return a.setTime(+t),r.setTime(+n),e(a),e(r),Math.floor(u(a,r))}),o}function n(e){return t(function(t){t.setHours(0,0,0,0),t.setDate(t.getDate()-(t.getDay()+7-e)%7)},function(e,t){e.setDate(e.getDate()+7*t)},function(e,t){return(t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/6048e5})}function u(e){return t(function(t){t.setUTCHours(0,0,0,0),t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7)},function(e,t){e.setUTCDate(e.getUTCDate()+7*t)},function(e,t){return(t-e)/6048e5})}var r=new Date,a=new Date,o=t(function(e){e.setMilliseconds(0)},function(e,t){e.setTime(+e+1e3*t)},function(e,t){return(t-e)/1e3});e.seconds=o.range;var s=t(function(e){e.setSeconds(0,0)},function(e,t){e.setTime(+e+6e4*t)},function(e,t){return(t-e)/6e4});e.minutes=s.range;var c=t(function(e){e.setMinutes(0,0,0)},function(e,t){e.setTime(+e+36e5*t)},function(e,t){return(t-e)/36e5});e.hours=c.range;var i=t(function(e){e.setHours(0,0,0,0)},function(e,t){e.setDate(e.getDate()+t)},function(e,t){return(t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5});e.days=i.range,e.sunday=n(0),e.sundays=e.sunday.range,e.monday=n(1),e.mondays=e.monday.range,e.tuesday=n(2),e.tuesdays=e.tuesday.range,e.wednesday=n(3),e.wednesdays=e.wednesday.range,e.thursday=n(4),e.thursdays=e.thursday.range,e.friday=n(5),e.fridays=e.friday.range,e.saturday=n(6),e.saturdays=e.saturday.range;var f=e.sunday;e.weeks=f.range;var d=t(function(e){e.setHours(0,0,0,0),e.setDate(1)},function(e,t){e.setMonth(e.getMonth()+t)},function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())});e.months=d.range;var g=t(function(e){e.setHours(0,0,0,0),e.setMonth(0,1)},function(e,t){e.setFullYear(e.getFullYear()+t)},function(e,t){return t.getFullYear()-e.getFullYear()});e.years=g.range;var y=t(function(e){e.setUTCMilliseconds(0)},function(e,t){e.setTime(+e+1e3*t)},function(e,t){return(t-e)/1e3});e.utcSeconds=y.range;var T=t(function(e){e.setUTCSeconds(0,0)},function(e,t){e.setTime(+e+6e4*t)},function(e,t){return(t-e)/6e4});e.utcMinutes=T.range;var l=t(function(e){e.setUTCMinutes(0,0,0)},function(e,t){e.setTime(+e+36e5*t)},function(e,t){return(t-e)/36e5});e.utcHours=l.range;var D=t(function(e){e.setUTCHours(0,0,0,0)},function(e,t){e.setUTCDate(e.getUTCDate()+t)},function(e,t){return(t-e)/864e5});e.utcDays=D.range,e.utcSunday=u(0),e.utcSundays=e.utcSunday.range,e.utcMonday=u(1),e.utcMondays=e.utcMonday.range,e.utcTuesday=u(2),e.utcTuesdays=e.utcTuesday.range,e.utcWednesday=u(3),e.utcWednesdays=e.utcWednesday.range,e.utcThursday=u(4),e.utcThursdays=e.utcThursday.range,e.utcFriday=u(5),e.utcFridays=e.utcFriday.range,e.utcSaturday=u(6),e.utcSaturdays=e.utcSaturday.range;var h=e.utcSunday;e.utcWeeks=h.range;var C=t(function(e){e.setUTCHours(0,0,0,0),e.setUTCDate(1)},function(e,t){e.setUTCMonth(e.getUTCMonth()+t)},function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())});e.utcMonths=C.range;var U=t(function(e){e.setUTCHours(0,0,0,0),e.setUTCMonth(0,1)},function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)},function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()});e.utcYears=U.range,e.second=o,e.minute=s,e.hour=c,e.day=i,e.week=f,e.month=d,e.year=g,e.utcSecond=y,e.utcMinute=T,e.utcHour=l,e.utcDay=D,e.utcWeek=h,e.utcMonth=C,e.utcYear=U}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.time={})}(this,function(e){"use strict";function t(e,n,u){function o(t){return e(t=new Date(+t)),t}return o.floor=o,o.round=function(t){var u=new Date(+t),r=new Date(t-1);return e(u),e(r),n(r,1),r-t>t-u?u:r},o.ceil=function(t){return e(t=new Date(t-1)),n(t,1),t},o.offset=function(e,t){return n(e=new Date(+e),null==t?1:Math.floor(t)),e},o.range=function(t,u,r){var a=[];if(t=new Date(t-1),u=new Date(+u),r=null==r?1:Math.floor(r),!(u>t&&r>0))return a;for(n(t,1),e(t),u>t&&a.push(new Date(+t));n(t,r),e(t),u>t;)a.push(new Date(+t));return a},o.filter=function(u){return t(function(t){for(;e(t),!u(t);)t.setTime(t-1)},function(e,t){for(;--t>=0;)for(;n(e,1),!u(e););})},u&&(o.count=function(t,n){return a.setTime(+t),r.setTime(+n),e(a),e(r),Math.floor(u(a,r))}),o}function n(e){return t(function(t){t.setHours(0,0,0,0),t.setDate(t.getDate()-(t.getDay()+7-e)%7)},function(e,t){e.setDate(e.getDate()+7*t)},function(e,t){return(t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/6048e5})}function u(e){return t(function(t){t.setUTCHours(0,0,0,0),t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7)},function(e,t){e.setUTCDate(e.getUTCDate()+7*t)},function(e,t){return(t-e)/6048e5})}var r=new Date,a=new Date,o=t(function(e){e.setMilliseconds(0)},function(e,t){e.setTime(+e+1e3*t)},function(e,t){return(t-e)/1e3});e.seconds=o.range;var s=t(function(e){e.setSeconds(0,0)},function(e,t){e.setTime(+e+6e4*t)},function(e,t){return(t-e)/6e4});e.minutes=s.range;var c=t(function(e){e.setMinutes(0,0,0)},function(e,t){e.setTime(+e+36e5*t)},function(e,t){return(t-e)/36e5});e.hours=c.range;var i=t(function(e){e.setHours(0,0,0,0)},function(e,t){e.setDate(e.getDate()+t)},function(e,t){return(t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5});e.days=i.range,e.sunday=n(0),e.sundays=e.sunday.range,e.monday=n(1),e.mondays=e.monday.range,e.tuesday=n(2),e.tuesdays=e.tuesday.range,e.wednesday=n(3),e.wednesdays=e.wednesday.range,e.thursday=n(4),e.thursdays=e.thursday.range,e.friday=n(5),e.fridays=e.friday.range,e.saturday=n(6),e.saturdays=e.saturday.range;var f=e.sunday;e.weeks=f.range;var d=t(function(e){e.setHours(0,0,0,0),e.setDate(1)},function(e,t){e.setMonth(e.getMonth()+t)},function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())});e.months=d.range;var g=t(function(e){e.setHours(0,0,0,0),e.setMonth(0,1)},function(e,t){e.setFullYear(e.getFullYear()+t)},function(e,t){return t.getFullYear()-e.getFullYear()});e.years=g.range;var y=t(function(e){e.setUTCMilliseconds(0)},function(e,t){e.setTime(+e+1e3*t)},function(e,t){return(t-e)/1e3});e.utcSeconds=y.range;var T=t(function(e){e.setUTCSeconds(0,0)},function(e,t){e.setTime(+e+6e4*t)},function(e,t){return(t-e)/6e4});e.utcMinutes=T.range;var l=t(function(e){e.setUTCMinutes(0,0,0)},function(e,t){e.setTime(+e+36e5*t)},function(e,t){return(t-e)/36e5});e.utcHours=l.range;var D=t(function(e){e.setUTCHours(0,0,0,0)},function(e,t){e.setUTCDate(e.getUTCDate()+t)},function(e,t){return(t-e)/864e5});e.utcDays=D.range,e.utcSunday=u(0),e.utcSundays=e.utcSunday.range,e.utcMonday=u(1),e.utcMondays=e.utcMonday.range,e.utcTuesday=u(2),e.utcTuesdays=e.utcTuesday.range,e.utcWednesday=u(3),e.utcWednesdays=e.utcWednesday.range,e.utcThursday=u(4),e.utcThursdays=e.utcThursday.range,e.utcFriday=u(5),e.utcFridays=e.utcFriday.range,e.utcSaturday=u(6),e.utcSaturdays=e.utcSaturday.range;var h=e.utcSunday;e.utcWeeks=h.range;var C=t(function(e){e.setUTCHours(0,0,0,0),e.setUTCDate(1)},function(e,t){e.setUTCMonth(e.getUTCMonth()+t)},function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())});e.utcMonths=C.range;var U=t(function(e){e.setUTCHours(0,0,0,0),e.setUTCMonth(0,1)},function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)},function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()});e.utcYears=U.range,e.interval=t,e.second=o,e.minute=s,e.hour=c,e.day=i,e.week=f,e.month=d,e.year=g,e.utcSecond=y,e.utcMinute=T,e.utcHour=l,e.utcDay=D,e.utcWeek=h,e.utcMonth=C,e.utcYear=U}); |
@@ -0,1 +1,2 @@ | ||
import interval from "./src/interval"; | ||
import second from "./src/second"; | ||
@@ -48,2 +49,3 @@ import minute from "./src/minute"; | ||
export { | ||
interval, | ||
second, | ||
@@ -50,0 +52,0 @@ minute, |
{ | ||
"name": "d3-time", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A calculator for humanity’s peculiar conventions of time.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -106,2 +106,12 @@ # d3-time | ||
<a name="interval" href="#interval">#</a> <b>interval</b>(<i>floor</i>, <i>offset</i>[, <i>count</i>]) | ||
Constructs a new custom interval given the specified *floor* and *offset* functions and an optional *count* function. | ||
The *floor* function takes a single date as an argument and rounds it down to the nearest interval boundary. | ||
The *offset* function takes a date and an integer step as arguments and advances the specified date by the specified number of boundaries; the step may be positive, negative or zero. | ||
The optional *count* function takes a start date and an end date, already floored to the current interval, and returns the number of boundaries between the start (exclusive) and end (inclusive). If a *count* function is not specified, the returned interval does not expose a [count](#interval_count) method. Note: due to an internal optimization, the specified *count* function must not invoke *interval*.count on other time intervals. | ||
### Intervals | ||
@@ -108,0 +118,0 @@ |
@@ -5,6 +5,6 @@ import interval from "./interval"; | ||
date.setHours(0, 0, 0, 0); | ||
}, function(date, offset) { | ||
date.setDate(date.getDate() + offset); | ||
}, function(date, step) { | ||
date.setDate(date.getDate() + step); | ||
}, function(start, end) { | ||
return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * 6e4) / 864e5; | ||
}); |
@@ -5,6 +5,6 @@ import interval from "./interval"; | ||
date.setMinutes(0, 0, 0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 36e5); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 36e5); | ||
}, function(start, end) { | ||
return (end - start) / 36e5; | ||
}); |
@@ -5,6 +5,6 @@ import interval from "./interval"; | ||
date.setSeconds(0, 0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 6e4); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 6e4); | ||
}, function(start, end) { | ||
return (end - start) / 6e4; | ||
}); |
@@ -6,6 +6,6 @@ import interval from "./interval"; | ||
date.setDate(1); | ||
}, function(date, offset) { | ||
date.setMonth(date.getMonth() + offset); | ||
}, function(date, step) { | ||
date.setMonth(date.getMonth() + step); | ||
}, function(start, end) { | ||
return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; | ||
}); |
@@ -5,6 +5,6 @@ import interval from "./interval"; | ||
date.setMilliseconds(0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 1e3); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 1e3); | ||
}, function(start, end) { | ||
return (end - start) / 1e3; | ||
}); |
@@ -5,6 +5,6 @@ import interval from "./interval"; | ||
date.setUTCHours(0, 0, 0, 0); | ||
}, function(date, offset) { | ||
date.setUTCDate(date.getUTCDate() + offset); | ||
}, function(date, step) { | ||
date.setUTCDate(date.getUTCDate() + step); | ||
}, function(start, end) { | ||
return (end - start) / 864e5; | ||
}); |
@@ -5,6 +5,6 @@ import interval from "./interval"; | ||
date.setUTCMinutes(0, 0, 0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 36e5); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 36e5); | ||
}, function(start, end) { | ||
return (end - start) / 36e5; | ||
}); |
@@ -5,6 +5,6 @@ import interval from "./interval"; | ||
date.setUTCSeconds(0, 0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 6e4); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 6e4); | ||
}, function(start, end) { | ||
return (end - start) / 6e4; | ||
}); |
@@ -6,6 +6,6 @@ import interval from "./interval"; | ||
date.setUTCDate(1); | ||
}, function(date, offset) { | ||
date.setUTCMonth(date.getUTCMonth() + offset); | ||
}, function(date, step) { | ||
date.setUTCMonth(date.getUTCMonth() + step); | ||
}, function(start, end) { | ||
return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; | ||
}); |
@@ -5,6 +5,6 @@ import interval from "./interval"; | ||
date.setUTCMilliseconds(0); | ||
}, function(date, offset) { | ||
date.setTime(+date + offset * 1e3); | ||
}, function(date, step) { | ||
date.setTime(+date + step * 1e3); | ||
}, function(start, end) { | ||
return (end - start) / 1e3; | ||
}); |
@@ -7,4 +7,4 @@ import interval from "./interval"; | ||
date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); | ||
}, function(date, offset) { | ||
date.setUTCDate(date.getUTCDate() + offset * 7); | ||
}, function(date, step) { | ||
date.setUTCDate(date.getUTCDate() + step * 7); | ||
}, function(start, end) { | ||
@@ -11,0 +11,0 @@ return (end - start) / 6048e5; |
@@ -6,6 +6,6 @@ import interval from "./interval"; | ||
date.setUTCMonth(0, 1); | ||
}, function(date, offset) { | ||
date.setUTCFullYear(date.getUTCFullYear() + offset); | ||
}, function(date, step) { | ||
date.setUTCFullYear(date.getUTCFullYear() + step); | ||
}, function(start, end) { | ||
return end.getUTCFullYear() - start.getUTCFullYear(); | ||
}); |
@@ -7,4 +7,4 @@ import interval from "./interval"; | ||
date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); | ||
}, function(date, offset) { | ||
date.setDate(date.getDate() + offset * 7); | ||
}, function(date, step) { | ||
date.setDate(date.getDate() + step * 7); | ||
}, function(start, end) { | ||
@@ -11,0 +11,0 @@ return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * 6e4) / 6048e5; |
@@ -6,6 +6,6 @@ import interval from "./interval"; | ||
date.setMonth(0, 1); | ||
}, function(date, offset) { | ||
date.setFullYear(date.getFullYear() + offset); | ||
}, function(date, step) { | ||
date.setFullYear(date.getFullYear() + step); | ||
}, function(start, end) { | ||
return end.getFullYear() - start.getFullYear(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38733
472
275