1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.dynamicFormatDateTime = void 0;
|
4 | function fillZero(digit) {
|
5 | if (Math.abs(digit) > 10)
|
6 | return String(digit);
|
7 | return digit.toString().padStart(2, '0');
|
8 | }
|
9 | function dynamicFormatDateTime(date) {
|
10 | const year = date.getFullYear();
|
11 | const month = fillZero(date.getMonth() + 1);
|
12 | const day = fillZero(date.getDate());
|
13 | const yyyyMMDD = `${year}-${month}-${day}`;
|
14 | const hour = date.getHours();
|
15 | const minutes = date.getMinutes();
|
16 | const seconds = date.getSeconds();
|
17 | if (hour || minutes || seconds)
|
18 | return `${yyyyMMDD} ${fillZero(hour)}:${fillZero(minutes)}:${fillZero(seconds)}`;
|
19 | return yyyyMMDD;
|
20 | }
|
21 | exports.dynamicFormatDateTime = dynamicFormatDateTime;
|
22 |
|
\ | No newline at end of file |