Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
web-monitor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
web-monitor
Commits
f32b49e6
Commit
f32b49e6
authored
Oct 22, 2019
by
花裤衩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf[utils.js]: perf parseTime function
parent
0e8fa655
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
7 deletions
+4
-7
index.js
src/utils/index.js
+4
-7
No files found.
src/utils/index.js
View file @
f32b49e6
...
...
@@ -6,7 +6,7 @@
* Parse the time to string
* @param {(Object|string|number)} time
* @param {string} cFormat
* @returns {string}
* @returns {string
| null
}
*/
export
function
parseTime
(
time
,
cFormat
)
{
if
(
arguments
.
length
===
0
)
{
...
...
@@ -34,14 +34,11 @@ export function parseTime(time, cFormat) {
s
:
date
.
getSeconds
(),
a
:
date
.
getDay
()
}
const
time_str
=
format
.
replace
(
/{
(
y|m|d|h|i|s|a
)
+}/g
,
(
result
,
key
)
=>
{
le
t
value
=
formatObj
[
key
]
const
time_str
=
format
.
replace
(
/{
(
[
ymdhisa
]
)
+}/g
,
(
result
,
key
)
=>
{
cons
t
value
=
formatObj
[
key
]
// Note: getDay() returns 0 on Sunday
if
(
key
===
'a'
)
{
return
[
'日'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
][
value
]
}
if
(
result
.
length
>
0
&&
value
<
10
)
{
value
=
'0'
+
value
}
return
value
||
0
return
value
.
toString
().
padStart
(
2
,
'0'
)
})
return
time_str
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment