-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (29 loc) · 984 Bytes
/
index.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
module.exports = (int, string) => {
if (!int || !string) {
throw "Int or String not provided";
return
}
if (string === 'seconds' || string === 'second') {
return int * 1000
}
if (string === 'minutes' || string === 'minute') {
return int * 60000
}
if (string === 'hours' || string === 'hour') {
return int * 3600000
}
if (string === 'days' || string === 'day') {
return int * 86400000
}
if (string === 'months' || string === 'month') {
var hoursInAMonth = 730.001 // according to the tome of Google
var millisecondsInAMonth = hoursInAMonth * 3600000
return int * millisecondsInAMonth
}
if (string === 'years' || string === 'year') {
var hoursInAYear = 8760 // according to the tome of Google
var millisecondsInAYear = hoursInAYear * 3600000
return int * millisecondsInAYear
}
throw new Error(`Time '${string}' not supported.`)
}