utils updated
This commit is contained in:
1 parent
10f5e96616
commit
328c36a53a
2 files changed
+3
-25
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
|
* Return a closure that compares a Number argument with specified Number
|
||||||
* @param withNumber Number to compare with
|
* @param withNumber Number to compare with
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
import {range} from './common';
|
import { range } from 'lodash'
|
||||||
|
|
||||||
/**
|
export function getDates(start: Date) {
|
||||||
*
|
|
||||||
* @param start
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
export function getDates(start) {
|
|
||||||
const oneDay = (1000 * 60 * 60 * 24);
|
const oneDay = (1000 * 60 * 60 * 24);
|
||||||
const startTime = start.getTime();
|
const startTime = start.getTime();
|
||||||
const startDay = start.getDay();
|
const startDay = start.getDay();
|
||||||
|
|
||||||
return range(0, 6, 1)
|
return range(0, 6)
|
||||||
.reduce((dates, weekDay) => {
|
.reduce((dates, weekDay) => {
|
||||||
let delta = 1 + weekDay - startDay;
|
let delta = 1 + weekDay - startDay;
|
||||||
let time = startTime + (oneDay * delta);
|
let time = startTime + (oneDay * delta);
|
||||||
Reference in new issue
Block a user