123456789101112131415161718192021222324252627 |
- "use strict";
- exports.isProtectedDayOfYearToken = isProtectedDayOfYearToken;
- exports.isProtectedWeekYearToken = isProtectedWeekYearToken;
- exports.warnOrThrowProtectedError = warnOrThrowProtectedError;
- const dayOfYearTokenRE = /^D+$/;
- const weekYearTokenRE = /^Y+$/;
- const throwTokens = ["D", "DD", "YY", "YYYY"];
- function isProtectedDayOfYearToken(token) {
- return dayOfYearTokenRE.test(token);
- }
- function isProtectedWeekYearToken(token) {
- return weekYearTokenRE.test(token);
- }
- 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`;
- }
|