{"size": 804, "ext": "js", "max_stars_repo_path": "helpers/date.js", "max_stars_repo_name": "nmaggioni/unifi-webex-dl", "max_stars_repo_stars_event_min_datetime": "2020-10-18T06:38:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T12:26:32.000Z", "max_issues_repo_path": "helpers/date.js", "max_issues_repo_name": "nmaggioni/unifi-webex-dl", "max_issues_repo_issues_event_min_datetime": "2021-09-29T13:05:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-08T14:45:24.000Z", "max_forks_repo_path": "helpers/date.js", "max_forks_repo_name": "nmaggioni/unifi-webex-dl", "max_forks_repo_forks_event_min_datetime": "2020-11-02T21:42:13.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-28T09:09:21.000Z"}
{"max_stars_count": 19, "max_issues_count": 4, "max_forks_count": 2, "avg_line_length": 26.8, "max_line_length": 77, "alphanum_fraction": 0.6355721393}
/**
 * Converts the given date to UTC format: YYYYMMDD
 * @param {string} date The date string
 * @param {string} separator The separator to place in between year,month,day
 * @returns {string}
 */
function getUTCDateTimestamp(date, separator = '') {
    const d = new Date(date);
    return [
        pad0(''+d.getUTCFullYear(), 4),
        pad0(''+(d.getUTCMonth()+1), 2),
        pad0(''+d.getUTCDate(), 2)
    ].join(separator);
}

/**
 * Prepend the given text with 0s up to length
 * @param {string} text the text to pad with 0
 * @param {number} length the length of the resulting string
 * @returns {string}
 */
function pad0(text, length = 0) {
    const pad = text.length < length ? '0'.repeat(length - text.length) : '';
    return pad + text;
}

module.exports = {
    getUTCDateTimestamp
};
