UNPKG

@itsmworkbench/utils

Version:

The usual utility functions

17 lines (16 loc) 609 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatDate = void 0; const formatDate = (template) => (date) => { const pad = (n) => n.toString().padStart(2, '0'); const replacements = { 'YYYY': date.getUTCFullYear().toString(), 'MM': pad(date.getUTCMonth() + 1), 'DD': pad(date.getUTCDate()), 'HH': pad(date.getUTCHours()), 'mm': pad(date.getUTCMinutes()), 'ss': pad(date.getUTCSeconds()) }; return template.replace(/YYYY|MM|DD|HH|mm|ss/g, match => replacements[match]); }; exports.formatDate = formatDate;