File tree Expand file tree Collapse file tree 3 files changed +8
-36
lines changed Expand file tree Collapse file tree 3 files changed +8
-36
lines changed Original file line number Diff line number Diff line change 1
- import padZero from './pad-zero' ;
1
+ function padTwoDigits ( data : number ) : string {
2
+ return String ( data ) . padStart ( 2 , '0' ) ;
3
+ }
2
4
3
5
export default function dateStringify ( date : unknown ) : string {
4
6
if ( date instanceof Date ) {
5
7
return (
6
8
date . getFullYear ( ) +
7
9
'/' +
8
- padZero ( 2 , date . getMonth ( ) + 1 ) +
10
+ padTwoDigits ( date . getMonth ( ) + 1 ) +
9
11
'/' +
10
- padZero ( 2 , date . getDate ( ) ) +
12
+ padTwoDigits ( date . getDate ( ) ) +
11
13
' ' +
12
- padZero ( 2 , date . getHours ( ) ) +
14
+ padTwoDigits ( date . getHours ( ) ) +
13
15
':' +
14
- padZero ( 2 , date . getMinutes ( ) ) +
16
+ padTwoDigits ( date . getMinutes ( ) ) +
15
17
':' +
16
- padZero ( 2 , date . getSeconds ( ) )
18
+ padTwoDigits ( date . getSeconds ( ) )
17
19
) ;
18
20
}
19
21
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments