utils updated
This commit is contained in:
1 parent
10f5e96616
commit
328c36a53a
2 files changed
+4
-26
No files matched your search
@@ -1,20 +1,3 @@
|
||||
/**
|
||||
* Generates list of numbers
|
||||
* @param {Number} start starting value
|
||||
* @param {Number} num amount of numbers in list
|
||||
* @param {Number} step difference value
|
||||
* @return {Array} list of numbers
|
||||
*/
|
||||
export function range(start, num, step) {
|
||||
var list = [];
|
||||
var val = start;
|
||||
for (var i = 0; i < num; i++) {
|
||||
list.push(val);
|
||||
val += step;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a closure that compares a Number argument with specified Number
|
||||
* @param withNumber Number to compare with
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import {range} from './common';
|
||||
import { range } from 'lodash'
|
||||
|
||||
/**
|
||||
*
|
||||
* @param start
|
||||
* @returns {*}
|
||||
*/
|
||||
export function getDates(start) {
|
||||
export function getDates(start: Date) {
|
||||
const oneDay = (1000 * 60 * 60 * 24);
|
||||
const startTime = start.getTime();
|
||||
const startDay = start.getDay();
|
||||
|
||||
return range(0, 6, 1)
|
||||
return range(0, 6)
|
||||
.reduce((dates, weekDay) => {
|
||||
let delta = 1 + weekDay - startDay;
|
||||
let time = startTime + (oneDay * delta);
|
||||
@@ -18,4 +13,4 @@ export function getDates(start) {
|
||||
return dates.concat([new Date(time)]);
|
||||
}, [])
|
||||
.map(i => i.getDate());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user