-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverif-params.js
43 lines (37 loc) · 889 Bytes
/
verif-params.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
function verifDayParam(day) {
if((day < 1 || day > 31) || isNaN(day) || day === undefined) {
day = new Date().getDate();
} else {
if(day < 10) {
day = day.slice(-1);
} else {
day = day.slice(-2);
}
}
return day;
}
function verifMonthParam(month) {
if((month < 1 || month > 12) || isNaN(month) || month === undefined) {
month = new Date().getMonth() + 1;
} else {
if(month < 10) {
month = month.slice(-1);
} else {
month = month.slice(-2);
}
}
return month;
}
function verifYearParam(year) {
if(year < 1970 || isNaN(year) || year === undefined) {
year = new Date().getFullYear();
} else {
year = year.slice(-4);
}
return year;
}
module.exports = {
verifDayParam,
verifMonthParam,
verifYearParam
}