-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adopt const, arrow; drop default exports
- Loading branch information
Showing
18 changed files
with
251 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
import interval from "./interval.js"; | ||
import {timeInterval} from "./interval.js"; | ||
import {durationDay, durationMinute} from "./duration.js"; | ||
|
||
var day = interval( | ||
export const timeDay = timeInterval( | ||
date => date.setHours(0, 0, 0, 0), | ||
(date, step) => date.setDate(date.getDate() + step), | ||
(start, end) => (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay, | ||
date => date.getDate() - 1 | ||
); | ||
|
||
export default day; | ||
export var days = day.range; | ||
export const timeDays = timeDay.range; | ||
|
||
export const utcDay = timeInterval((date) => { | ||
date.setUTCHours(0, 0, 0, 0); | ||
}, (date, step) => { | ||
date.setUTCDate(date.getUTCDate() + step); | ||
}, (start, end) => { | ||
return (end - start) / durationDay; | ||
}, (date) => { | ||
return date.getUTCDate() - 1; | ||
}); | ||
|
||
export const utcDays = utcDay.range; | ||
|
||
export const unixDay = timeInterval((date) => { | ||
date.setUTCHours(0, 0, 0, 0); | ||
}, (date, step) => { | ||
date.setUTCDate(date.getUTCDate() + step); | ||
}, (start, end) => { | ||
return (end - start) / durationDay; | ||
}, (date) => { | ||
return Math.floor(date / durationDay); | ||
}); | ||
|
||
export const unixDays = unixDay.range; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
import interval from "./interval.js"; | ||
import {timeInterval} from "./interval.js"; | ||
import {durationHour, durationMinute, durationSecond} from "./duration.js"; | ||
|
||
var hour = interval(function(date) { | ||
export const timeHour = timeInterval((date) => { | ||
date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); | ||
}, function(date, step) { | ||
}, (date, step) => { | ||
date.setTime(+date + step * durationHour); | ||
}, function(start, end) { | ||
}, (start, end) => { | ||
return (end - start) / durationHour; | ||
}, function(date) { | ||
}, (date) => { | ||
return date.getHours(); | ||
}); | ||
|
||
export default hour; | ||
export var hours = hour.range; | ||
export const timeHours = timeHour.range; | ||
|
||
export const utcHour = timeInterval((date) => { | ||
date.setUTCMinutes(0, 0, 0); | ||
}, (date, step) => { | ||
date.setTime(+date + step * durationHour); | ||
}, (start, end) => { | ||
return (end - start) / durationHour; | ||
}, (date) => { | ||
return date.getUTCHours(); | ||
}); | ||
|
||
export const utcHours = utcHour.range; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
import interval from "./interval.js"; | ||
import {timeInterval} from "./interval.js"; | ||
|
||
var millisecond = interval(function() { | ||
export const millisecond = timeInterval(() => { | ||
// noop | ||
}, function(date, step) { | ||
}, (date, step) => { | ||
date.setTime(+date + step); | ||
}, function(start, end) { | ||
}, (start, end) => { | ||
return end - start; | ||
}); | ||
|
||
// An optimized implementation for this simple case. | ||
millisecond.every = function(k) { | ||
millisecond.every = (k) => { | ||
k = Math.floor(k); | ||
if (!isFinite(k) || !(k > 0)) return null; | ||
if (!(k > 1)) return millisecond; | ||
return interval(function(date) { | ||
return timeInterval((date) => { | ||
date.setTime(Math.floor(date / k) * k); | ||
}, function(date, step) { | ||
}, (date, step) => { | ||
date.setTime(+date + step * k); | ||
}, function(start, end) { | ||
}, (start, end) => { | ||
return (end - start) / k; | ||
}); | ||
}; | ||
|
||
export default millisecond; | ||
export var milliseconds = millisecond.range; | ||
export const milliseconds = millisecond.range; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
import interval from "./interval.js"; | ||
import {timeInterval} from "./interval.js"; | ||
import {durationMinute, durationSecond} from "./duration.js"; | ||
|
||
var minute = interval(function(date) { | ||
export const timeMinute = timeInterval((date) => { | ||
date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); | ||
}, function(date, step) { | ||
}, (date, step) => { | ||
date.setTime(+date + step * durationMinute); | ||
}, function(start, end) { | ||
}, (start, end) => { | ||
return (end - start) / durationMinute; | ||
}, function(date) { | ||
}, (date) => { | ||
return date.getMinutes(); | ||
}); | ||
|
||
export default minute; | ||
export var minutes = minute.range; | ||
export const timeMinutes = timeMinute.range; | ||
|
||
export const utcMinute = timeInterval((date) => { | ||
date.setUTCSeconds(0, 0); | ||
}, (date, step) => { | ||
date.setTime(+date + step * durationMinute); | ||
}, (start, end) => { | ||
return (end - start) / durationMinute; | ||
}, (date) => { | ||
return date.getUTCMinutes(); | ||
}); | ||
|
||
export const utcMinutes = utcMinute.range; |
Oops, something went wrong.