index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* eslint-disable no-console */
  2. export default (function (o, c, d) {
  3. if (!process || process.env.NODE_ENV !== 'production') {
  4. var proto = c.prototype;
  5. var oldParse = proto.parse;
  6. proto.parse = function (cfg) {
  7. var date = cfg.date;
  8. if (typeof date === 'string' && date.length === 13) {
  9. console.warn("To parse a Unix timestamp like " + date + ", you should pass it as a Number. https://day.js.org/docs/en/parse/unix-timestamp-milliseconds");
  10. }
  11. if (typeof date === 'number' && String(date).length === 4) {
  12. console.warn("Guessing you may want to parse the Year " + date + ", you should pass it as a String " + date + ", not a Number. Otherwise, " + date + " will be treated as a Unix timestamp");
  13. }
  14. if (cfg.args.length >= 2 && !d.p.customParseFormat) {
  15. console.warn("To parse a date-time string like " + date + " using the given format, you should enable customParseFormat plugin first. https://day.js.org/docs/en/parse/string-format");
  16. }
  17. return oldParse.bind(this)(cfg);
  18. };
  19. var oldLocale = d.locale;
  20. d.locale = function (preset, object, isLocal) {
  21. if (typeof object === 'undefined' && typeof preset === 'string') {
  22. if (!d.Ls[preset]) {
  23. console.warn("Guessing you may want to use locale " + preset + ", you have to load it before using it. https://day.js.org/docs/en/i18n/loading-into-nodejs");
  24. }
  25. }
  26. return oldLocale(preset, object, isLocal);
  27. };
  28. }
  29. });