We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6e54155 commit 54eebf4Copy full SHA for 54eebf4
src/utils/date-stringify.ts
@@ -1,19 +1,21 @@
1
-import padZero from './pad-zero';
+function padTwoDigits(data: number): string {
2
+ return String(data).padStart(2, '0');
3
+}
4
5
export default function dateStringify(date: unknown): string {
6
if (date instanceof Date) {
7
return (
8
date.getFullYear() +
9
'/' +
- padZero(2, date.getMonth() + 1) +
10
+ padTwoDigits(date.getMonth() + 1) +
11
- padZero(2, date.getDate()) +
12
+ padTwoDigits(date.getDate()) +
13
' ' +
- padZero(2, date.getHours()) +
14
+ padTwoDigits(date.getHours()) +
15
':' +
- padZero(2, date.getMinutes()) +
16
+ padTwoDigits(date.getMinutes()) +
17
- padZero(2, date.getSeconds())
18
+ padTwoDigits(date.getSeconds())
19
);
20
}
21
test/unit/utils-pad-zero.js
0 commit comments