-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.js
33 lines (26 loc) · 907 Bytes
/
Utils.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
module.exports = {
getDateTime: () => {
var date = new Date();
var hour = date.getHours();
hour = (hour < 10 ? "0" : "") + hour;
var min = date.getMinutes();
min = (min < 10 ? "0" : "") + min;
var sec = date.getSeconds();
sec = (sec < 10 ? "0" : "") + sec;
var year = date.getFullYear();
var month = date.getMonth() + 1;
month = (month < 10 ? "0" : "") + month;
var day = date.getDate();
day = (day < 10 ? "0" : "") + day;
return (year + ":" + month + ":" + day + " - " + hour + ":" + min + ":" + sec);
},
char_count: (str, letter) => {
var letter_Count = 0;
for (var position = 0; position < str.length; position++) {
if (str.charAt(position) == letter) {
letter_Count += 1;
}
}
return letter_Count;
}
};