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