UNPKG

1.54 kBJavaScriptView Raw
1/* eslint-disable no-console */
2export default (function (o, c, d) {
3 /* istanbul ignore next line */
4 if (!process || process.env.NODE_ENV !== 'production') {
5 var proto = c.prototype;
6 var oldParse = proto.parse;
7
8 proto.parse = function (cfg) {
9 var date = cfg.date;
10
11 if (typeof date === 'string' && date.length === 13) {
12 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");
13 }
14
15 if (typeof date === 'number' && String(date).length === 4) {
16 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");
17 }
18
19 if (cfg.args.length >= 2 && !d.p.customParseFormat) {
20 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");
21 }
22
23 return oldParse.bind(this)(cfg);
24 };
25
26 var oldLocale = d.locale;
27
28 d.locale = function (preset, object, isLocal) {
29 if (typeof object === 'undefined' && typeof preset === 'string') {
30 if (!d.Ls[preset]) {
31 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");
32 }
33 }
34
35 return oldLocale(preset, object, isLocal);
36 };
37 }
38});
\No newline at end of file