@antv/g2
Version:
the Grammar of Graphics in Javascript
22 lines • 821 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.dynamicFormatDateTime = void 0;
function fillZero(digit) {
if (Math.abs(digit) > 10)
return String(digit);
return digit.toString().padStart(2, '0');
}
function dynamicFormatDateTime(date) {
const year = date.getFullYear();
const month = fillZero(date.getMonth() + 1);
const day = fillZero(date.getDate());
const yyyyMMDD = `${year}-${month}-${day}`;
const hour = date.getHours();
const minutes = date.getMinutes();
const seconds = date.getSeconds();
if (hour || minutes || seconds)
return `${yyyyMMDD} ${fillZero(hour)}:${fillZero(minutes)}:${fillZero(seconds)}`;
return yyyyMMDD;
}
exports.dynamicFormatDateTime = dynamicFormatDateTime;
//# sourceMappingURL=dateFormat.js.map
;