-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.js
35 lines (32 loc) · 783 Bytes
/
util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Should only be called using apply, call, or bind with **this** set to a valid Date instance
* @param {number} h
* @returns {Date | undefined}
*/
function addHours(h) {
if (this instanceof Date) {
this.setHours(this.getHours() + h)
return this
}
return undefined
}
/**
* Should only be called using apply, call, or bind with **this** set to a valid Date instance
* @param {number} h
* @returns {Date | undefined}
*/
function addMinutes(m) {
if (this instanceof Date) {
this.setMinutes(this.getMinutes() + m)
return this
}
return undefined
}
const hoursToMiliSecondsFactor = 1000 * 60 * 60
const minutesToMiliSecondsFactor = 1000 * 60
module.exports = {
addHours,
addMinutes,
hoursToMiliSecondsFactor,
minutesToMiliSecondsFactor,
}