const dayOfYearTokenRE = /^D+$/; const weekYearTokenRE = /^Y+$/; const throwTokens = ["D", "DD", "YY", "YYYY"]; export function isProtectedDayOfYearToken(token) { return dayOfYearTokenRE.test(token); } export function isProtectedWeekYearToken(token) { return weekYearTokenRE.test(token); } export function warnOrThrowProtectedError(token, format, input) { const _message = message(token, format, input); console.warn(_message); if (throwTokens.includes(token)) throw new RangeError(_message); } function message(token, format, input) { const subject = token[0] === "Y" ? "years" : "days of the month"; return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`; }