forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeInterval.js
More file actions
29 lines (26 loc) · 968 Bytes
/
timeInterval.js
File metadata and controls
29 lines (26 loc) · 968 Bytes
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
'use strict';
class TimeInterval {
constructor(day, domain, intervals) {
this.domain = domain;
if (intervals != undefined)
this.intervals = intervals;
else this.intervals = [];
this.day = day;
}
addInterval() {
var date = new Date();
var stringDate = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
this.intervals.push(stringDate + '-' + stringDate);
}
closeInterval() {
var today = new Date();
var stringDate = today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds();
var currentInterval = this.intervals[this.intervals.length - 1];
if (currentInterval != undefined) {
if (currentInterval.split('-')[0] == currentInterval.split('-')[1]) {
this.intervals.pop();
this.intervals.push(currentInterval.split('-')[0] + '-' + stringDate);
}
}
}
};