forked from Taewan-P/military-duty-calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult.html
99 lines (80 loc) · 3.17 KB
/
result.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Military Duty Calcurator</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="hayeong">
<meta name="description" content="Calcurate a date of user's discharge">
<meta name="copyright" content="BSD-3-Clause">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<!-- <script src="main.js"></script> -->
</head>
<body>
<script>
var getParam = function(key){
var _parammap = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
_parammap[decode(arguments[1])] = decode(arguments[2]);
});
return _parammap[key];
};
var date = getParam('date')
var total_month = getParam('month')
p = document.createElement('h1')
p.innerHTML = date + "에 입대하는 당신은.....\n"
document.body.appendChild(p)
p = document.createElement('h2')
p.innerHTML = total_month + "개월간 복무하셔야 합니다."
document.body.appendChild(p)
finish_date = dateAddDel(date, (parseInt(total_month)-1), 'm').toUTCString()
var year = finish_date.split(' ')[3]
var month = engtoKor(finish_date.split(' ')[2])
var day = finish_date.split(' ')[1]
var result_text = year + "년 " + month + "월 " + day + "일에 전역 예정입니다."
c = document.createElement('h3')
c.innerHTML = result_text
document.body.appendChild(c)
function dateAddDel(sDate, nNum, type) {
var yy = parseInt(sDate.substr(0, 4), 10);
var mm = parseInt(sDate.substr(5, 2), 10);
var dd = parseInt(sDate.substr(8), 10);
if (type == "d") {
d = new Date(yy, mm - 1, dd + nNum);
}
else if (type == "m") {
d = new Date(yy, mm - 1 + nNum, dd);
}
else if (type == "y") {
d = new Date(yy + nNum, mm - 1, dd);
}
yy = d.getFullYear();
mm = d.getMonth() + 1; mm = (mm < 10) ? '0' + mm : mm;
dd = d.getDate(); dd = (dd < 10) ? '0' + dd : dd;
var result = new Date(yy, mm, dd);
// console.log(result)
// result.setDate(result.getDate()-1)
return result
}
function engtoKor(month) {
if (month == "Jan") { return '1'}
else if (month == "Feb") { return '2' }
else if (month == "Mar") { return '3' }
else if (month == "Apr") { return '4' }
else if (month == "May") { return '5' }
else if (month == "Jun") { return '6' }
else if (month == "Jul") { return '7' }
else if (month == "Aug") { return '8' }
else if (month == "Sep") { return '9' }
else if (month == "Oct") { return '10' }
else if (month == "Nov") { return '11' }
else if (month == "Dec") { return '12' }
}
</script>
<!-- <input id="continue" type="button" name="submit" onclick="javascript:buttonClick();" value="다시"> -->
</body>
</html>