<commit_before>const { CRON: { allowedNum, partRegex, day, predefined, tokens, tokensRegex } } = require('./constants');

/**
 * Handles Cron strings and generates dates based on the cron string provided.
 * @see https://en.wikipedia.org/wiki/Cron
 */
class Cron {

	/**
	 * @since 0.5.0
	 * @param {string} cron The cron pattern to use
	 */
	constructor(cron) {
		this.cron = this.constructor._normalize(cron.toLowerCase());
		[this.minutes, this.hours, this.days, this.months, this.dows] = this.constructor._parseString(this.cron);
	}

	/**
	 * Get the next date that matches with the current pattern
	 * @since 0.5.0
	 * @param {Date} zDay The Date instance to compare with
	 * @param {boolean} origin Whether this next call is origin
	 * @returns {Date}
	 */
	next(zDay = new Date(), origin = true) {
		if (this.days.includes(zDay.getUTCDate()) && this.months.includes(zDay.getUTCMonth() + 1) && this.dows.includes(zDay.getUTCDay())) {
			const now = new Date(zDay.getTime() + 60000);
			const hour = origin ? this.hours.find(hr => hr >= now.getUTCHours()) : this.hours[0];
			const minute = origin ? this.minutes.find(min => min >= now.getUTCMinutes()) : this.minutes[0];
			if (typeof hour !== 'undefined' && typeof hour !== 'undefined') {
				return new Date(Date.UTC(zDay.getUTCFullYear(), zDay.getUTCMonth(), zDay.getUTCDate(), hour, minute));
			}
		}
		return this.next(new Date(zDay.getTime() + day), false);
	}

	/**
	 * Normalize the pattern<commit_msg>Cron bugfix<commit_after>const { CRON: { allowedNum, partRegex, day, predefined, tokens, tokensRegex } } = require('./constants');

/**
 * Handles Cron strings and generates dates based on the cron string provided.
 * @see https://en.wikipedia.org/wiki/Cron
 */
class Cron {

	/**
	 * @since 0.5.0
	 * @param {string} cron The cron pattern to use
	 */
	constructor(cron) {
		this.cron = this.constructor._normalize(cron.toLowerCase());
		[this.minutes, this.hours, this.days, this.months, this.dows] = this.constructor._parseString(this.cron);
	}

	/**
	 * Get the next date that matches with the current pattern
	 * @since 0.5.0
	 * @param {Date} zDay The Date instance to compare with
	 * @param {boolean} origin Whether this next call is origin
	 * @returns {Date}
	 */
	next(zDay = new Date(), origin = true) {
		if (this.days.includes(zDay.getUTCDate()) && this.months.includes(zDay.getUTCMonth() + 1) && this.dows.includes(zDay.getUTCDay())) {
			const now = new Date(zDay.getTime() + 60000);
			const hour = origin ? this.hours.find(hr => hr >= now.getUTCHours()) : this.hours[0];
			const minute = origin ? this.minutes.find(min => min >= now.getUTCMinutes()) : this.minutes[0];
			if (typeof hour !== 'undefined' && typeof minute !== 'undefined') {
				return new Date(Date.UTC(zDay.getUTCFullYear(), zDay.getUTCMonth(), zDay.getUTCDate(), hour, minute));
			}
		}
		return this.next(new Date(zDay.getTime() + day), false);
	}

	/**
	 * Normalize the pattern
{'fraction_non_alphanumeric': 0.16223585548738922, 'fraction_numerical': 0.00954328561690525, 'mean_word_length': 3.8916666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3786814', 'n_tokens_mistral': 1052, 'n_tokens_neox': 967, 'n_words': 254}