Toggle navigation
Toggle navigation
This project
Loading...
Sign in
HyeonJun Jeon
/
Extended-Calendar
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
HyeonJun Jeon
2022-06-04 20:49:17 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c2a7942524d9c18196c6db2fff510b84d22d0d5c
c2a79425
1 parent
8aa32fac
[FIx] Date location UTC to local
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
server/libs/ICal.js
server/libs/ICal.js
View file @
c2a7942
...
...
@@ -25,12 +25,10 @@ function process(sche, k, v) {
case
"DTSTART"
:
sche
.
scheType
=
"time"
;
sche
.
date
=
getDatestr
(
v
);
k
=
"startTime"
;
v
=
getTimestr
(
v
);
break
;
return
;
case
"DTEND"
:
k
=
"endTime"
;
v
=
sche
.
startTime
;
v
=
getTimestr_z
(
v
)
;
break
;
case
"DTSTART;VALUE=DATE"
:
sche
.
scheType
=
"date"
;
...
...
@@ -73,14 +71,29 @@ function insert(str, idxs, char) {
return
nstr
;
}
/**
* parse DateString
* @param {string} str "YYYYMMDDTHHMMSS"
* @returns {string} "YYYY-MM-DD"
*/
function
getDatestr
(
str
)
{
const
a
=
str
.
substring
(
0
,
str
.
indexOf
(
"T"
));
return
insert
(
a
,
[
4
,
6
,
8
],
"-"
);
}
function
getTimestr
(
str
)
{
const
b
=
str
.
substring
(
str
.
indexOf
(
"T"
)
+
1
);
return
insert
(
b
,
[
2
,
4
,
6
],
":"
);
/**
* parse ZDateString
* @param {string} zstr "YYYYMMDDTHHMMSSZ" (UTC)
* @returns {string} "HH:MM:SS" (UTC+9)
*/
function
getTimestr_z
(
zstr
)
{
const
it
=
zstr
.
indexOf
(
"T"
);
const
a
=
zstr
.
substring
(
0
,
it
);
const
b
=
zstr
.
substring
(
it
+
1
,
zstr
.
length
-
1
);
const
date
=
new
Date
(
insert
(
a
,
[
4
,
6
,
8
],
"-"
)
+
"T"
+
insert
(
b
,
[
2
,
4
,
6
],
":"
)
+
"+00:00"
);
return
date
.
toTimeString
().
substring
(
0
,
8
);
}
// const fdata = fs.readFileSync("C:/Users/teddy/Downloads/data.ics", "utf8");
...
...
Please
register
or
login
to post a comment