1 |
|
2 | export default (function (option, dayjsClass) {
|
3 | var oldParse = dayjsClass.prototype.parse;
|
4 |
|
5 | dayjsClass.prototype.parse = function (cfg) {
|
6 | if (typeof cfg.date === 'string') {
|
7 | var locale = this.$locale();
|
8 | cfg.date = locale && locale.preparse ? locale.preparse(cfg.date) : cfg.date;
|
9 | }
|
10 |
|
11 |
|
12 | return oldParse.bind(this)(cfg);
|
13 | };
|
14 |
|
15 |
|
16 |
|
17 | var oldFormat = dayjsClass.prototype.format;
|
18 |
|
19 | dayjsClass.prototype.format = function () {
|
20 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
21 | args[_key] = arguments[_key];
|
22 | }
|
23 |
|
24 |
|
25 | var result = oldFormat.call.apply(oldFormat, [this].concat(args));
|
26 |
|
27 | var locale = this.$locale();
|
28 | return locale && locale.postformat ? locale.postformat(result) : result;
|
29 | };
|
30 |
|
31 | var oldFromTo = dayjsClass.prototype.fromToBase;
|
32 |
|
33 | if (oldFromTo) {
|
34 | dayjsClass.prototype.fromToBase = function (input, withoutSuffix, instance, isFrom) {
|
35 | var locale = this.$locale() || instance.$locale();
|
36 |
|
37 | return oldFromTo.call(this, input, withoutSuffix, instance, isFrom, locale && locale.postformat);
|
38 | };
|
39 | }
|
40 | }); |
\ | No newline at end of file |