1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.differenceInDays = differenceInDays;
|
7 | var DAY = 60 * 60 * 24;
|
8 | var HOUR = 60 * 60;
|
9 | var MINUTE = 60;
|
10 | var SECOND = 1;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function differenceInDays(start, end) {
|
24 | var startDate = start ? new Date(start) : new Date();
|
25 | var endDate = new Date(end);
|
26 | var difference = Math.abs(endDate.getTime() - startDate.getTime()) / 1000;
|
27 |
|
28 | var days = Math.floor(difference / DAY);
|
29 | var hours = Math.floor((difference - days * DAY) / HOUR);
|
30 | var minutes = Math.floor((difference - days * DAY - hours * HOUR) / MINUTE);
|
31 | var seconds = Math.floor((difference - days * DAY - hours * HOUR - minutes * MINUTE) / SECOND);
|
32 |
|
33 | return {
|
34 | days: days,
|
35 | hours: hours,
|
36 | minutes: minutes,
|
37 | seconds: seconds
|
38 | };
|
39 | } |
\ | No newline at end of file |