Toggle navigation
Toggle navigation
This project
Loading...
Sign in
teamPARK
/
holiday-counter-recommend-activity
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박지환
2022-05-17 11:43:13 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5aeb7f0ed4d4b6525e29716efd18409e207ce779
5aeb7f0e
1 parent
5c436990
Implemented as a function & Add get today date
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
47 deletions
feature-holiday-counter/.vscode/launch.json
feature-holiday-counter/app.js
server.js
views/data.ejs
feature-holiday-counter/.vscode/launch.json
deleted
100644 → 0
View file @
5c43699
{
//
IntelliSense를
사용하여
가능한
특성에
대해
알아보세요.
//
기존
특성에
대한
설명을
보려면
가리킵니다.
//
자세한
내용을
보려면
https
:
//go.microsoft.com/fwlink/?linkid=
830387
을(를)
방문하세요.
"version"
:
"0.2.0"
,
"configurations"
:
[
{
"type"
:
"pwa-node"
,
"request"
:
"launch"
,
"name"
:
"Launch Program"
,
"skipFiles"
:
[
"<node_internals>/**"
],
"program"
:
"${workspaceFolder}
\\
app.js"
}
]
}
\ No newline at end of file
feature-holiday-counter/app.js
deleted
100644 → 0
View file @
5c43699
const
today
=
new
Date
();
//오늘 날짜 입력
const
holiday
=
new
Date
(
"2022-10-01"
);
//공휴일 날짜 입력
console
.
log
(
today
.
getMonth
()
+
1
);
const
diffDate
=
today
.
getTime
()
-
holiday
.
getTime
();
const
dday
=
Math
.
abs
(
diffDate
/
(
1000
*
3600
*
24
));
console
.
log
(
dday
);
server.js
View file @
5aeb7f0
...
...
@@ -31,6 +31,41 @@ var tempArr = [];
app
.
set
(
"views"
,
__dirname
+
"/views"
);
app
.
set
(
"view engine"
,
"ejs"
);
// To get today date by using Date
function
getTodayDate
()
{
var
today
=
new
Date
();
var
year
=
today
.
getFullYear
();
var
month
=
(
"0"
+
(
today
.
getMonth
()
+
1
)).
slice
(
-
2
);
var
day
=
(
"0"
+
today
.
getDate
()).
slice
(
-
2
);
var
dateString
=
year
+
"-"
+
month
+
"-"
+
day
;
return
dateString
;
}
// To get modified date from locdate
function
getModifiedDate
(
locdate
)
{
return
(
locdate
.
substr
(
0
,
4
)
+
"-"
+
locdate
.
substr
(
4
,
2
)
+
"-"
+
locdate
.
substr
(
6
,
2
)
);
}
// To get remaining days from locdate
function
getDate
(
dateName
,
locdate
)
{
var
today
=
new
Date
(
getTodayDate
());
// today date
var
holiday
=
new
Date
(
getModifiedDate
(
locdate
));
// holiday date
var
diffDate
=
today
.
getTime
()
-
holiday
.
getTime
();
var
dday
=
Math
.
abs
(
diffDate
/
(
1000
*
3600
*
24
));
console
.
log
(
dateName
+
"까지 "
+
dday
+
"일 남았습니다."
);
return
dday
;
}
// To initialize datas when calling webpage
function
init
()
{
request
.
get
(
requestUrl
,
(
err
,
res
,
body
)
=>
{
if
(
err
)
{
...
...
@@ -74,27 +109,12 @@ function init() {
locdate
.
push
(
tempStr
);
idx
=
text
.
indexOf
(
"locdate"
,
idx
+
1
);
}
let
i
=
0
;
let
length
=
dateName
.
length
;
console
.
log
(
locdate
)
;
// Get date through locdate
var
holiArr
=
[];
while
(
i
<
length
)
{
var
temptoday
=
dateName
[
i
];
var
tempdate
=
locdate
[
i
];
var
modifiedDate
=
tempdate
.
substr
(
0
,
4
)
+
"-"
+
tempdate
.
substr
(
4
,
2
)
+
"-"
+
tempdate
.
substr
(
6
,
2
);
var
today
=
new
Date
(
"2022-05-13"
);
//오늘 날짜 입력
var
holiday
=
new
Date
(
modifiedDate
);
//공휴일 날짜 입력
var
diffDate
=
today
.
getTime
()
-
holiday
.
getTime
();
var
dday
=
Math
.
abs
(
diffDate
/
(
1000
*
3600
*
24
));
console
.
log
(
temptoday
+
"까지 "
+
dday
+
"일 남았습니다."
);
holiArr
.
push
(
dday
);
i
++
;
for
(
var
i
=
0
;
i
<
dateName
.
length
;
i
++
)
{
holiArr
.
push
(
getDate
(
dateName
[
i
],
locdate
[
i
]));
}
console
.
log
(
locdate
);
// Create tempArr to save dateName and locdate at once
tempArr
=
[];
tempArr
.
push
(
dateName
);
...
...
views/data.ejs
View file @
5aeb7f0
<!-- data.ejs -->
<!DOCTYPE html>
<html
lang=
"en"
>
<html>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
...
...
Please
register
or
login
to post a comment