-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.js
43 lines (40 loc) · 1.14 KB
/
time.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
36
37
38
39
40
41
42
43
/**
* Number of complete days between two dates
*
* @param {Date} StartDate
* @param {Date} EndDate
* @return {string} Number of complete days between StartDate end EndDate
*/
function dayDiff(StartDate, EndDate) {
return Math.floor((EndDate - StartDate) / (1000 * 60 * 60 * 24));
}
/**
* Number of complete hours between two dates
*
* @param {Date} StartDate
* @param {Date} EndDate
* @return {string} Number of complete hours between StartDate end EndDate
*/
function hourDiff(StartDate, EndDate) {
return Math.floor((EndDate - StartDate) / (1000 * 60 * 60));
}
/**
* Number of complete minutes between two dates
*
* @param {Date} StartDate
* @param {Date} EndDate
* @return {string} Number of complete minutes between StartDate end EndDate
*/
function minuteDiff(StartDate, EndDate) {
return Math.floor((EndDate - StartDate) / (1000 * 60));
}
/**
* Number of complete seconds between two dates
*
* @param {Date} StartDate
* @param {Date} EndDate
* @return {string} Number of complete seconds between StartDate end EndDate
*/
function secondDiff(StartDate, EndDate) {
return Math.floor((EndDate - StartDate) / (1000));
}