index.js 1.6 KB

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.isProtectedDayOfYearToken = isProtectedDayOfYearToken;
  6. exports.isProtectedWeekYearToken = isProtectedWeekYearToken;
  7. exports.throwProtectedError = throwProtectedError;
  8. var protectedDayOfYearTokens = ['D', 'DD'];
  9. var protectedWeekYearTokens = ['YY', 'YYYY'];
  10. function isProtectedDayOfYearToken(token) {
  11. return protectedDayOfYearTokens.indexOf(token) !== -1;
  12. }
  13. function isProtectedWeekYearToken(token) {
  14. return protectedWeekYearTokens.indexOf(token) !== -1;
  15. }
  16. function throwProtectedError(token, format, input) {
  17. if (token === 'YYYY') {
  18. throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
  19. } else if (token === 'YY') {
  20. throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
  21. } else if (token === 'D') {
  22. throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
  23. } else if (token === 'DD') {
  24. throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
  25. }
  26. }