"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatDate = void 0;
const zeroPad_1 = require("@astral/utils/zeroPad");
const maskDate_1 = require("../maskDate");
const elementsMap = {
    [maskDate_1.DateMaskElements.Day]: (date) => date.getUTCDate(),
    [maskDate_1.DateMaskElements.Month]: (date) => date.getUTCMonth() + 1,
    [maskDate_1.DateMaskElements.Year]: (date) => date.getUTCFullYear(),
    [maskDate_1.DateMaskElements.Hour]: (date) => date.getUTCHours(),
    [maskDate_1.DateMaskElements.Minute]: (date) => date.getUTCMinutes(),
    [maskDate_1.DateMaskElements.Second]: (date) => date.getUTCSeconds(),
};
/**
 * утилита для генерации строковой даты по заданной маске
 */
const formatDate = (date, mask, separator = '.') => mask
    .split(separator)
    .map((element) => elementsMap[element]?.(date))
    .filter(Number.isInteger)
    .map((value) => (0, zeroPad_1.zeroPad)(value, 2))
    .join(separator);
exports.formatDate = formatDate;
