@nocobase/plugin-backup-restore 2.2.20 → 2.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/externalVersion.js +5 -5
- package/dist/node_modules/@hapi/topo/package.json +1 -1
- package/dist/node_modules/@xhmikosr/decompress/package.json +1 -1
- package/dist/node_modules/archiver/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/moment/LICENSE +1 -1
- package/dist/node_modules/moment/dist/locale/am-et.js +62 -0
- package/dist/node_modules/moment/dist/locale/ar-dz.js +8 -8
- package/dist/node_modules/moment/dist/locale/ar-ly.js +8 -8
- package/dist/node_modules/moment/dist/locale/ar-ps.js +112 -0
- package/dist/node_modules/moment/dist/locale/ar.js +8 -8
- package/dist/node_modules/moment/dist/locale/be.js +2 -2
- package/dist/node_modules/moment/dist/locale/bs.js +14 -4
- package/dist/node_modules/moment/dist/locale/ca.js +7 -7
- package/dist/node_modules/moment/dist/locale/cs.js +5 -4
- package/dist/node_modules/moment/dist/locale/cv.js +2 -2
- package/dist/node_modules/moment/dist/locale/de-at.js +29 -1
- package/dist/node_modules/moment/dist/locale/de-ch.js +29 -1
- package/dist/node_modules/moment/dist/locale/de.js +29 -1
- package/dist/node_modules/moment/dist/locale/en-au.js +6 -6
- package/dist/node_modules/moment/dist/locale/en-ca.js +6 -6
- package/dist/node_modules/moment/dist/locale/en-gb.js +6 -6
- package/dist/node_modules/moment/dist/locale/en-ie.js +6 -6
- package/dist/node_modules/moment/dist/locale/en-il.js +6 -6
- package/dist/node_modules/moment/dist/locale/en-in.js +6 -6
- package/dist/node_modules/moment/dist/locale/en-nz.js +6 -6
- package/dist/node_modules/moment/dist/locale/en-sg.js +6 -6
- package/dist/node_modules/moment/dist/locale/hu.js +3 -3
- package/dist/node_modules/moment/dist/locale/id.js +12 -1
- package/dist/node_modules/moment/dist/locale/it.js +4 -4
- package/dist/node_modules/moment/dist/locale/ka.js +1 -1
- package/dist/node_modules/moment/dist/locale/ku-kmr.js +121 -0
- package/dist/node_modules/moment/dist/locale/lt.js +2 -2
- package/dist/node_modules/moment/dist/locale/me.js +2 -2
- package/dist/node_modules/moment/dist/locale/nb.js +4 -4
- package/dist/node_modules/moment/dist/locale/nl-be.js +2 -2
- package/dist/node_modules/moment/dist/locale/nl.js +1 -1
- package/dist/node_modules/moment/dist/locale/oc-lnc.js +6 -6
- package/dist/node_modules/moment/dist/locale/pl.js +1 -1
- package/dist/node_modules/moment/dist/locale/ps.js +177 -0
- package/dist/node_modules/moment/dist/locale/pt-br.js +14 -6
- package/dist/node_modules/moment/dist/locale/ru.js +2 -2
- package/dist/node_modules/moment/dist/locale/sv.js +7 -7
- package/dist/node_modules/moment/dist/locale/sw.js +56 -14
- package/dist/node_modules/moment/dist/locale/tet.js +6 -6
- package/dist/node_modules/moment/dist/locale/tlh.js +8 -8
- package/dist/node_modules/moment/dist/locale/tzl.js +2 -2
- package/dist/node_modules/moment/dist/locale/uk.js +9 -8
- package/dist/node_modules/moment/dist/locale/uz-latn.js +1 -1
- package/dist/node_modules/moment/dist/locale/uz.js +1 -1
- package/dist/node_modules/moment/dist/locale/x-pseudo.js +6 -6
- package/dist/node_modules/moment/dist/moment.js +1274 -1042
- package/dist/node_modules/moment/dojo.profile.js +11 -0
- package/dist/node_modules/moment/ender.js +1 -1
- package/dist/node_modules/moment/locale/am-et.js +73 -0
- package/dist/node_modules/moment/locale/ar-dz.js +8 -8
- package/dist/node_modules/moment/locale/ar-ly.js +8 -8
- package/dist/node_modules/moment/locale/ar-ps.js +123 -0
- package/dist/node_modules/moment/locale/ar.js +8 -8
- package/dist/node_modules/moment/locale/be.js +2 -2
- package/dist/node_modules/moment/locale/bm.js +2 -0
- package/dist/node_modules/moment/locale/bs.js +14 -4
- package/dist/node_modules/moment/locale/ca.js +7 -7
- package/dist/node_modules/moment/locale/cs.js +5 -4
- package/dist/node_modules/moment/locale/cv.js +2 -2
- package/dist/node_modules/moment/locale/de-at.js +29 -1
- package/dist/node_modules/moment/locale/de-ch.js +29 -1
- package/dist/node_modules/moment/locale/de.js +29 -1
- package/dist/node_modules/moment/locale/en-au.js +6 -6
- package/dist/node_modules/moment/locale/en-ca.js +6 -6
- package/dist/node_modules/moment/locale/en-gb.js +6 -6
- package/dist/node_modules/moment/locale/en-ie.js +6 -6
- package/dist/node_modules/moment/locale/en-il.js +6 -6
- package/dist/node_modules/moment/locale/en-in.js +6 -6
- package/dist/node_modules/moment/locale/en-nz.js +6 -6
- package/dist/node_modules/moment/locale/en-sg.js +6 -6
- package/dist/node_modules/moment/locale/hu.js +3 -3
- package/dist/node_modules/moment/locale/id.js +12 -1
- package/dist/node_modules/moment/locale/it.js +4 -4
- package/dist/node_modules/moment/locale/ka.js +1 -1
- package/dist/node_modules/moment/locale/ku-kmr.js +125 -0
- package/dist/node_modules/moment/locale/lt.js +2 -2
- package/dist/node_modules/moment/locale/me.js +2 -2
- package/dist/node_modules/moment/locale/mk.js +0 -1
- package/dist/node_modules/moment/locale/nb.js +4 -4
- package/dist/node_modules/moment/locale/nl-be.js +2 -2
- package/dist/node_modules/moment/locale/nl.js +1 -1
- package/dist/node_modules/moment/locale/oc-lnc.js +6 -6
- package/dist/node_modules/moment/locale/pl.js +1 -1
- package/dist/node_modules/moment/locale/ps.js +188 -0
- package/dist/node_modules/moment/locale/pt-br.js +14 -6
- package/dist/node_modules/moment/locale/ru.js +2 -2
- package/dist/node_modules/moment/locale/sv.js +7 -7
- package/dist/node_modules/moment/locale/sw.js +56 -14
- package/dist/node_modules/moment/locale/tet.js +6 -6
- package/dist/node_modules/moment/locale/tlh.js +8 -8
- package/dist/node_modules/moment/locale/tzl.js +2 -2
- package/dist/node_modules/moment/locale/uk.js +9 -8
- package/dist/node_modules/moment/locale/uz-latn.js +1 -1
- package/dist/node_modules/moment/locale/uz.js +1 -1
- package/dist/node_modules/moment/locale/x-pseudo.js +6 -6
- package/dist/node_modules/moment/min/locales.js +1380 -771
- package/dist/node_modules/moment/min/locales.min.js +211 -1
- package/dist/node_modules/moment/min/moment-with-locales.js +2705 -1858
- package/dist/node_modules/moment/min/moment-with-locales.min.js +216 -1
- package/dist/node_modules/moment/min/moment.min.js +8 -1
- package/dist/node_modules/moment/moment.d.ts +2 -0
- package/dist/node_modules/moment/moment.js +3 -3
- package/dist/node_modules/moment/package.json +1 -1
- package/dist/node_modules/moment/src/lib/create/check-overflow.js +15 -15
- package/dist/node_modules/moment/src/lib/create/from-array.js +77 -10
- package/dist/node_modules/moment/src/lib/create/from-string-and-array.js +2 -0
- package/dist/node_modules/moment/src/lib/create/parsing-flags.js +1 -0
- package/dist/node_modules/moment/src/lib/create/valid.js +25 -24
- package/dist/node_modules/moment/src/lib/duration/as.js +3 -15
- package/dist/node_modules/moment/src/lib/duration/bubble.js +4 -6
- package/dist/node_modules/moment/src/lib/duration/humanize.js +14 -3
- package/dist/node_modules/moment/src/lib/format/format.js +7 -4
- package/dist/node_modules/moment/src/lib/locale/en.js +6 -6
- package/dist/node_modules/moment/src/lib/locale/formats.js +19 -3
- package/dist/node_modules/moment/src/lib/locale/locales.js +33 -13
- package/dist/node_modules/moment/src/lib/locale/relative.js +25 -2
- package/dist/node_modules/moment/src/lib/locale/set.js +4 -0
- package/dist/node_modules/moment/src/lib/moment/calendar.js +10 -10
- package/dist/node_modules/moment/src/lib/moment/get-set.js +66 -22
- package/dist/node_modules/moment/src/lib/moment/min-max.js +15 -3
- package/dist/node_modules/moment/src/lib/parse/regex.js +4 -0
- package/dist/node_modules/moment/src/lib/units/aliases.js +50 -6
- package/dist/node_modules/moment/src/lib/units/day-of-month.js +7 -11
- package/dist/node_modules/moment/src/lib/units/day-of-week.js +52 -21
- package/dist/node_modules/moment/src/lib/units/day-of-year.js +0 -9
- package/dist/node_modules/moment/src/lib/units/era.js +13 -7
- package/dist/node_modules/moment/src/lib/units/hour.js +5 -12
- package/dist/node_modules/moment/src/lib/units/millisecond.js +0 -10
- package/dist/node_modules/moment/src/lib/units/minute.js +7 -12
- package/dist/node_modules/moment/src/lib/units/month.js +38 -28
- package/dist/node_modules/moment/src/lib/units/offset.js +13 -1
- package/dist/node_modules/moment/src/lib/units/priorities.js +18 -5
- package/dist/node_modules/moment/src/lib/units/quarter.js +0 -10
- package/dist/node_modules/moment/src/lib/units/second.js +7 -12
- package/dist/node_modules/moment/src/lib/units/week-calendar-utils.js +22 -8
- package/dist/node_modules/moment/src/lib/units/week-year.js +1 -11
- package/dist/node_modules/moment/src/lib/units/week.js +8 -15
- package/dist/node_modules/moment/src/lib/units/year.js +0 -10
- package/dist/node_modules/moment/src/lib/utils/deprecate.js +1 -1
- package/dist/node_modules/moment/src/locale/am-et.js +62 -0
- package/dist/node_modules/moment/src/locale/ar-dz.js +8 -8
- package/dist/node_modules/moment/src/locale/ar-ly.js +8 -8
- package/dist/node_modules/moment/src/locale/ar-ps.js +112 -0
- package/dist/node_modules/moment/src/locale/ar.js +8 -8
- package/dist/node_modules/moment/src/locale/be.js +2 -2
- package/dist/node_modules/moment/src/locale/bs.js +14 -4
- package/dist/node_modules/moment/src/locale/ca.js +7 -7
- package/dist/node_modules/moment/src/locale/cs.js +5 -4
- package/dist/node_modules/moment/src/locale/cv.js +2 -2
- package/dist/node_modules/moment/src/locale/de-at.js +29 -1
- package/dist/node_modules/moment/src/locale/de-ch.js +29 -1
- package/dist/node_modules/moment/src/locale/de.js +29 -1
- package/dist/node_modules/moment/src/locale/en-au.js +6 -6
- package/dist/node_modules/moment/src/locale/en-ca.js +6 -6
- package/dist/node_modules/moment/src/locale/en-gb.js +6 -6
- package/dist/node_modules/moment/src/locale/en-ie.js +6 -6
- package/dist/node_modules/moment/src/locale/en-il.js +6 -6
- package/dist/node_modules/moment/src/locale/en-in.js +6 -6
- package/dist/node_modules/moment/src/locale/en-nz.js +6 -6
- package/dist/node_modules/moment/src/locale/en-sg.js +6 -6
- package/dist/node_modules/moment/src/locale/hu.js +3 -3
- package/dist/node_modules/moment/src/locale/id.js +12 -1
- package/dist/node_modules/moment/src/locale/it.js +4 -4
- package/dist/node_modules/moment/src/locale/ka.js +1 -1
- package/dist/node_modules/moment/src/locale/ku-kmr.js +121 -0
- package/dist/node_modules/moment/src/locale/lt.js +2 -2
- package/dist/node_modules/moment/src/locale/me.js +2 -2
- package/dist/node_modules/moment/src/locale/nb.js +4 -4
- package/dist/node_modules/moment/src/locale/nl-be.js +2 -2
- package/dist/node_modules/moment/src/locale/nl.js +1 -1
- package/dist/node_modules/moment/src/locale/oc-lnc.js +6 -6
- package/dist/node_modules/moment/src/locale/pl.js +1 -1
- package/dist/node_modules/moment/src/locale/ps.js +177 -0
- package/dist/node_modules/moment/src/locale/pt-br.js +14 -6
- package/dist/node_modules/moment/src/locale/ru.js +2 -2
- package/dist/node_modules/moment/src/locale/sv.js +7 -7
- package/dist/node_modules/moment/src/locale/sw.js +56 -14
- package/dist/node_modules/moment/src/locale/tet.js +6 -6
- package/dist/node_modules/moment/src/locale/tlh.js +8 -8
- package/dist/node_modules/moment/src/locale/tzl.js +2 -2
- package/dist/node_modules/moment/src/locale/uk.js +9 -8
- package/dist/node_modules/moment/src/locale/uz-latn.js +1 -1
- package/dist/node_modules/moment/src/locale/uz.js +1 -1
- package/dist/node_modules/moment/src/locale/x-pseudo.js +6 -6
- package/dist/node_modules/moment/src/moment.js +2 -2
- package/dist/node_modules/moment/ts3.1-typings/moment.d.ts +258 -78
- package/dist/node_modules/semver/package.json +1 -1
- package/package.json +2 -2
- package/dist/node_modules/moment/package.js +0 -11
|
@@ -2,7 +2,7 @@ import { hooks } from '../utils/hooks';
|
|
|
2
2
|
import { createDate, createUTCDate } from './date-from-array';
|
|
3
3
|
import { daysInYear } from '../units/year';
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
weekOfYearFromDate,
|
|
6
6
|
weeksInYear,
|
|
7
7
|
dayOfYearFromWeeks,
|
|
8
8
|
} from '../units/week-calendar-utils';
|
|
@@ -19,9 +19,46 @@ import { createLocal } from './local';
|
|
|
19
19
|
import defaults from '../utils/defaults';
|
|
20
20
|
import getParsingFlags from './parsing-flags';
|
|
21
21
|
|
|
22
|
-
function currentDateArray(config) {
|
|
22
|
+
function currentDateArray(config, now, forWeek) {
|
|
23
|
+
var hadWeekContext = Object.prototype.hasOwnProperty.call(
|
|
24
|
+
config,
|
|
25
|
+
'_isDefaultDatePartsForWeek'
|
|
26
|
+
),
|
|
27
|
+
weekContext = config._isDefaultDatePartsForWeek;
|
|
28
|
+
|
|
23
29
|
// hooks is actually the exported moment object
|
|
24
|
-
|
|
30
|
+
config._isDefaultDatePartsForWeek = !!forWeek;
|
|
31
|
+
try {
|
|
32
|
+
return hooks._getDefaultDateParts(config, now, forWeek);
|
|
33
|
+
} finally {
|
|
34
|
+
if (hadWeekContext) {
|
|
35
|
+
config._isDefaultDatePartsForWeek = weekContext;
|
|
36
|
+
} else {
|
|
37
|
+
delete config._isDefaultDatePartsForWeek;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function currentDateNow(config) {
|
|
43
|
+
var now = config._defaultDatePartsNow;
|
|
44
|
+
|
|
45
|
+
if (!now) {
|
|
46
|
+
return hooks.now();
|
|
47
|
+
}
|
|
48
|
+
if (!now.hasValue) {
|
|
49
|
+
now.value = hooks.now();
|
|
50
|
+
now.hasValue = true;
|
|
51
|
+
}
|
|
52
|
+
return now.value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Internal hook for extensions that supply omitted calendar fields.
|
|
56
|
+
function getDefaultDateParts(config, now, forWeek) {
|
|
57
|
+
var useWeekDefaults = forWeek || config._isDefaultDatePartsForWeek,
|
|
58
|
+
nowValue = useWeekDefaults ? createLocal(now) : new Date(now);
|
|
59
|
+
if (useWeekDefaults) {
|
|
60
|
+
return [nowValue.year(), nowValue.month(), nowValue.date()];
|
|
61
|
+
}
|
|
25
62
|
if (config._useUTC) {
|
|
26
63
|
return [
|
|
27
64
|
nowValue.getUTCFullYear(),
|
|
@@ -32,6 +69,8 @@ function currentDateArray(config) {
|
|
|
32
69
|
return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
|
|
33
70
|
}
|
|
34
71
|
|
|
72
|
+
hooks._getDefaultDateParts = getDefaultDateParts;
|
|
73
|
+
|
|
35
74
|
// convert an array to a date.
|
|
36
75
|
// the array should mirror the parameters below
|
|
37
76
|
// note: all values past the year are optional and will default to the lowest possible value.
|
|
@@ -40,24 +79,34 @@ export function configFromArray(config) {
|
|
|
40
79
|
var i,
|
|
41
80
|
date,
|
|
42
81
|
input = [],
|
|
82
|
+
now,
|
|
43
83
|
currentDate,
|
|
44
84
|
expectedWeekday,
|
|
45
|
-
yearToUse
|
|
85
|
+
yearToUse,
|
|
86
|
+
dateIsDefaulted;
|
|
46
87
|
|
|
47
88
|
if (config._d) {
|
|
48
89
|
return;
|
|
49
90
|
}
|
|
50
91
|
|
|
51
|
-
|
|
92
|
+
if (
|
|
93
|
+
config._a[YEAR] == null ||
|
|
94
|
+
config._a[MONTH] == null ||
|
|
95
|
+
config._a[DATE] == null
|
|
96
|
+
) {
|
|
97
|
+
now = currentDateNow(config);
|
|
98
|
+
currentDate = currentDateArray(config, now);
|
|
99
|
+
}
|
|
52
100
|
|
|
53
101
|
//compute day of the year from weeks and weekdays
|
|
54
102
|
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
|
55
|
-
dayOfYearFromWeekInfo(config);
|
|
103
|
+
dayOfYearFromWeekInfo(config, currentDateArray(config, now, true));
|
|
56
104
|
}
|
|
57
105
|
|
|
58
106
|
//if the day of the year is set, figure out what it is
|
|
59
107
|
if (config._dayOfYear != null) {
|
|
60
|
-
yearToUse =
|
|
108
|
+
yearToUse =
|
|
109
|
+
config._a[YEAR] != null ? config._a[YEAR] : currentDate[YEAR];
|
|
61
110
|
|
|
62
111
|
if (
|
|
63
112
|
config._dayOfYear > daysInYear(yearToUse) ||
|
|
@@ -71,6 +120,11 @@ export function configFromArray(config) {
|
|
|
71
120
|
config._a[DATE] = date.getUTCDate();
|
|
72
121
|
}
|
|
73
122
|
|
|
123
|
+
dateIsDefaulted =
|
|
124
|
+
config._a[YEAR] == null ||
|
|
125
|
+
config._a[MONTH] == null ||
|
|
126
|
+
config._a[DATE] == null;
|
|
127
|
+
|
|
74
128
|
// Default to current date.
|
|
75
129
|
// * if no year, month, day of month are given, default to today
|
|
76
130
|
// * if day of month is given, default month and year
|
|
@@ -119,13 +173,14 @@ export function configFromArray(config) {
|
|
|
119
173
|
if (
|
|
120
174
|
config._w &&
|
|
121
175
|
typeof config._w.d !== 'undefined' &&
|
|
176
|
+
!dateIsDefaulted &&
|
|
122
177
|
config._w.d !== expectedWeekday
|
|
123
178
|
) {
|
|
124
179
|
getParsingFlags(config).weekdayMismatch = true;
|
|
125
180
|
}
|
|
126
181
|
}
|
|
127
182
|
|
|
128
|
-
function dayOfYearFromWeekInfo(config) {
|
|
183
|
+
function dayOfYearFromWeekInfo(config, currentDate) {
|
|
129
184
|
var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
|
|
130
185
|
|
|
131
186
|
w = config._w;
|
|
@@ -140,7 +195,13 @@ function dayOfYearFromWeekInfo(config) {
|
|
|
140
195
|
weekYear = defaults(
|
|
141
196
|
w.GG,
|
|
142
197
|
config._a[YEAR],
|
|
143
|
-
|
|
198
|
+
weekOfYearFromDate(
|
|
199
|
+
currentDate[YEAR],
|
|
200
|
+
currentDate[MONTH],
|
|
201
|
+
currentDate[DATE],
|
|
202
|
+
1,
|
|
203
|
+
4
|
|
204
|
+
).year
|
|
144
205
|
);
|
|
145
206
|
week = defaults(w.W, 1);
|
|
146
207
|
weekday = defaults(w.E, 1);
|
|
@@ -151,7 +212,13 @@ function dayOfYearFromWeekInfo(config) {
|
|
|
151
212
|
dow = config._locale._week.dow;
|
|
152
213
|
doy = config._locale._week.doy;
|
|
153
214
|
|
|
154
|
-
curWeek =
|
|
215
|
+
curWeek = weekOfYearFromDate(
|
|
216
|
+
currentDate[YEAR],
|
|
217
|
+
currentDate[MONTH],
|
|
218
|
+
currentDate[DATE],
|
|
219
|
+
dow,
|
|
220
|
+
doy
|
|
221
|
+
);
|
|
155
222
|
|
|
156
223
|
weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
|
|
157
224
|
|
|
@@ -13,6 +13,7 @@ export function configFromStringAndArray(config) {
|
|
|
13
13
|
currentScore,
|
|
14
14
|
validFormatFound,
|
|
15
15
|
bestFormatIsValid = false,
|
|
16
|
+
defaultDatePartsNow = {},
|
|
16
17
|
configfLen = config._f.length;
|
|
17
18
|
|
|
18
19
|
if (configfLen === 0) {
|
|
@@ -28,6 +29,7 @@ export function configFromStringAndArray(config) {
|
|
|
28
29
|
if (config._useUTC != null) {
|
|
29
30
|
tempConfig._useUTC = config._useUTC;
|
|
30
31
|
}
|
|
32
|
+
tempConfig._defaultDatePartsNow = defaultDatePartsNow;
|
|
31
33
|
tempConfig._f = config._f[i];
|
|
32
34
|
configFromStringAndFormat(tempConfig);
|
|
33
35
|
|
|
@@ -4,24 +4,26 @@ import getParsingFlags from '../create/parsing-flags';
|
|
|
4
4
|
import some from '../utils/some';
|
|
5
5
|
|
|
6
6
|
export function isValid(m) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
var flags = null,
|
|
8
|
+
parsedParts = false,
|
|
9
|
+
isNowValid = m._d && !isNaN(m._d.getTime());
|
|
10
|
+
if (isNowValid) {
|
|
11
|
+
flags = getParsingFlags(m);
|
|
12
|
+
parsedParts = some.call(flags.parsedDateParts, function (i) {
|
|
13
|
+
return i != null;
|
|
14
|
+
});
|
|
15
|
+
isNowValid =
|
|
16
|
+
flags.overflow < 0 &&
|
|
17
|
+
!flags.empty &&
|
|
18
|
+
!flags.invalidEra &&
|
|
19
|
+
!flags.invalidMonth &&
|
|
20
|
+
!flags.invalidOffset &&
|
|
21
|
+
!flags.invalidWeekday &&
|
|
22
|
+
!flags.weekdayMismatch &&
|
|
23
|
+
!flags.nullInput &&
|
|
24
|
+
!flags.invalidFormat &&
|
|
25
|
+
!flags.userInvalidated &&
|
|
26
|
+
(!flags.meridiem || (flags.meridiem && parsedParts));
|
|
25
27
|
if (m._strict) {
|
|
26
28
|
isNowValid =
|
|
27
29
|
isNowValid &&
|
|
@@ -29,12 +31,11 @@ export function isValid(m) {
|
|
|
29
31
|
flags.unusedTokens.length === 0 &&
|
|
30
32
|
flags.bigHour === undefined;
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
34
|
+
}
|
|
35
|
+
if (Object.isFrozen == null || !Object.isFrozen(m)) {
|
|
36
|
+
m._isValid = isNowValid;
|
|
37
|
+
} else {
|
|
38
|
+
return isNowValid;
|
|
38
39
|
}
|
|
39
40
|
return m._isValid;
|
|
40
41
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { daysToMonths, monthsToDays } from './bubble';
|
|
2
2
|
import { normalizeUnits } from '../units/aliases';
|
|
3
|
-
import toInt from '../utils/to-int';
|
|
4
3
|
|
|
5
4
|
export function as(units) {
|
|
6
5
|
if (!this.isValid()) {
|
|
@@ -46,19 +45,6 @@ export function as(units) {
|
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
// TODO: Use this.as('ms')?
|
|
50
|
-
export function valueOf() {
|
|
51
|
-
if (!this.isValid()) {
|
|
52
|
-
return NaN;
|
|
53
|
-
}
|
|
54
|
-
return (
|
|
55
|
-
this._milliseconds +
|
|
56
|
-
this._days * 864e5 +
|
|
57
|
-
(this._months % 12) * 2592e6 +
|
|
58
|
-
toInt(this._months / 12) * 31536e6
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
48
|
function makeAs(alias) {
|
|
63
49
|
return function () {
|
|
64
50
|
return this.as(alias);
|
|
@@ -73,7 +59,8 @@ var asMilliseconds = makeAs('ms'),
|
|
|
73
59
|
asWeeks = makeAs('w'),
|
|
74
60
|
asMonths = makeAs('M'),
|
|
75
61
|
asQuarters = makeAs('Q'),
|
|
76
|
-
asYears = makeAs('y')
|
|
62
|
+
asYears = makeAs('y'),
|
|
63
|
+
valueOf = asMilliseconds;
|
|
77
64
|
|
|
78
65
|
export {
|
|
79
66
|
asMilliseconds,
|
|
@@ -85,4 +72,5 @@ export {
|
|
|
85
72
|
asMonths,
|
|
86
73
|
asQuarters,
|
|
87
74
|
asYears,
|
|
75
|
+
valueOf,
|
|
88
76
|
};
|
|
@@ -14,12 +14,10 @@ export function bubble() {
|
|
|
14
14
|
|
|
15
15
|
// if we have a mix of positive and negative values, bubble down first
|
|
16
16
|
// check: https://github.com/moment/moment/issues/2166
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
) {
|
|
17
|
+
if (!(
|
|
18
|
+
(milliseconds >= 0 && days >= 0 && months >= 0) ||
|
|
19
|
+
(milliseconds <= 0 && days <= 0 && months <= 0)
|
|
20
|
+
)) {
|
|
23
21
|
milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
|
|
24
22
|
days = 0;
|
|
25
23
|
months = 0;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { createDuration } from './create';
|
|
2
|
+
import extend from '../utils/extend';
|
|
3
|
+
import {
|
|
4
|
+
relativeTimeWithoutPostformat,
|
|
5
|
+
pastFutureWithoutPostformat,
|
|
6
|
+
} from '../locale/relative';
|
|
2
7
|
|
|
3
8
|
var round = Math.round,
|
|
4
9
|
thresholds = {
|
|
@@ -13,7 +18,13 @@ var round = Math.round,
|
|
|
13
18
|
|
|
14
19
|
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
|
|
15
20
|
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
|
|
16
|
-
return
|
|
21
|
+
return relativeTimeWithoutPostformat.call(
|
|
22
|
+
locale,
|
|
23
|
+
number || 1,
|
|
24
|
+
!!withoutSuffix,
|
|
25
|
+
string,
|
|
26
|
+
isFuture
|
|
27
|
+
);
|
|
17
28
|
}
|
|
18
29
|
|
|
19
30
|
function relativeTime(posNegDuration, withoutSuffix, thresholds, locale) {
|
|
@@ -97,7 +108,7 @@ export function humanize(argWithSuffix, argThresholds) {
|
|
|
97
108
|
withSuffix = argWithSuffix;
|
|
98
109
|
}
|
|
99
110
|
if (typeof argThresholds === 'object') {
|
|
100
|
-
th =
|
|
111
|
+
th = extend(extend({}, thresholds), argThresholds || {});
|
|
101
112
|
if (argThresholds.s != null && argThresholds.ss == null) {
|
|
102
113
|
th.ss = argThresholds.s - 1;
|
|
103
114
|
}
|
|
@@ -107,7 +118,7 @@ export function humanize(argWithSuffix, argThresholds) {
|
|
|
107
118
|
output = relativeTime(this, !withSuffix, th, locale);
|
|
108
119
|
|
|
109
120
|
if (withSuffix) {
|
|
110
|
-
output =
|
|
121
|
+
output = pastFutureWithoutPostformat.call(locale, +this, output);
|
|
111
122
|
}
|
|
112
123
|
|
|
113
124
|
return locale.postformat(output);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import zeroFill from '../utils/zero-fill';
|
|
2
2
|
import isFunction from '../utils/is-function';
|
|
3
|
+
import hasOwnProp from '../utils/has-own-prop';
|
|
3
4
|
|
|
4
5
|
var formattingTokens =
|
|
5
|
-
/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
|
|
6
|
+
/(\[[^\[]*\])|(\\e)|(\\)?(eHHmm|[Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
|
|
6
7
|
localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
|
|
7
8
|
formatFunctions = {},
|
|
8
9
|
formatTokenFunctions = {};
|
|
@@ -77,10 +78,12 @@ export function formatMoment(m, format) {
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
format = expandFormat(format, m.localeData());
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
var cacheKey = '$' + format;
|
|
82
|
+
if (!hasOwnProp(formatFunctions, cacheKey)) {
|
|
83
|
+
formatFunctions[cacheKey] = makeFormatFunction(format);
|
|
84
|
+
}
|
|
82
85
|
|
|
83
|
-
return formatFunctions[
|
|
86
|
+
return formatFunctions[cacheKey](m);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
export function expandFormat(format, locale) {
|
|
@@ -28,12 +28,12 @@ getSetGlobalLocale('en', {
|
|
|
28
28
|
toInt((number % 100) / 10) === 1
|
|
29
29
|
? 'th'
|
|
30
30
|
: b === 1
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
? 'st'
|
|
32
|
+
: b === 2
|
|
33
|
+
? 'nd'
|
|
34
|
+
: b === 3
|
|
35
|
+
? 'rd'
|
|
36
|
+
: 'th';
|
|
37
37
|
return number + output;
|
|
38
38
|
},
|
|
39
39
|
});
|
|
@@ -11,13 +11,22 @@ export var defaultLongDateFormat = {
|
|
|
11
11
|
|
|
12
12
|
export function longDateFormat(key) {
|
|
13
13
|
var format = this._longDateFormat[key],
|
|
14
|
-
formatUpper = this._longDateFormat[key.toUpperCase()]
|
|
14
|
+
formatUpper = this._longDateFormat[key.toUpperCase()],
|
|
15
|
+
formatCache = this._longDateFormatCache;
|
|
15
16
|
|
|
16
17
|
if (format || !formatUpper) {
|
|
17
18
|
return format;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
if (
|
|
22
|
+
formatCache &&
|
|
23
|
+
formatCache[key] &&
|
|
24
|
+
formatCache[key].formatUpper === formatUpper
|
|
25
|
+
) {
|
|
26
|
+
return formatCache[key].format;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
format = formatUpper
|
|
21
30
|
.match(formattingTokens)
|
|
22
31
|
.map(function (tok) {
|
|
23
32
|
if (
|
|
@@ -32,5 +41,12 @@ export function longDateFormat(key) {
|
|
|
32
41
|
})
|
|
33
42
|
.join('');
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
if (!formatCache) {
|
|
45
|
+
formatCache = this._longDateFormatCache = {};
|
|
46
|
+
}
|
|
47
|
+
formatCache[key] = {
|
|
48
|
+
formatUpper: formatUpper,
|
|
49
|
+
format: format,
|
|
50
|
+
};
|
|
51
|
+
return format;
|
|
36
52
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import isArray from '../utils/is-array';
|
|
2
2
|
import isUndefined from '../utils/is-undefined';
|
|
3
|
+
import hasOwnProp from '../utils/has-own-prop';
|
|
3
4
|
import { deprecateSimple } from '../utils/deprecate';
|
|
4
5
|
import { mergeConfigs } from './set';
|
|
5
6
|
import { Locale } from './constructor';
|
|
@@ -63,33 +64,49 @@ function chooseLocale(names) {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
function isLocaleNameSane(name) {
|
|
66
|
-
//
|
|
67
|
-
return name
|
|
67
|
+
// Only canonical locale module names are safe to append to the require path.
|
|
68
|
+
return typeof name === 'string' && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
function loadLocale(name) {
|
|
71
72
|
var oldLocale = null,
|
|
72
|
-
aliasedRequire
|
|
73
|
+
aliasedRequire,
|
|
74
|
+
normalizedName;
|
|
75
|
+
|
|
76
|
+
// Preserve exact custom locale names before trying the canonical built-in name.
|
|
77
|
+
// Use hasOwnProp rather than a plain lookup so that names like "__proto__",
|
|
78
|
+
// "constructor", or "prototype" can't resolve to an inherited Object.prototype
|
|
79
|
+
// property instead of a real (or missing) locale entry.
|
|
80
|
+
if (hasOwnProp(locales, name)) {
|
|
81
|
+
return locales[name];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
normalizedName = normalizeLocale(name);
|
|
85
|
+
if (hasOwnProp(locales, normalizedName)) {
|
|
86
|
+
return locales[normalizedName];
|
|
87
|
+
}
|
|
88
|
+
|
|
73
89
|
// TODO: Find a better way to register and load all the locales in Node
|
|
74
90
|
if (
|
|
75
|
-
locales[name] === undefined &&
|
|
76
91
|
typeof module !== 'undefined' &&
|
|
77
92
|
module &&
|
|
78
93
|
module.exports &&
|
|
79
|
-
isLocaleNameSane(
|
|
94
|
+
isLocaleNameSane(normalizedName)
|
|
80
95
|
) {
|
|
81
96
|
try {
|
|
82
97
|
oldLocale = globalLocale._abbr;
|
|
83
98
|
aliasedRequire = require;
|
|
84
|
-
aliasedRequire('./locale/' +
|
|
99
|
+
aliasedRequire('./locale/' + normalizedName);
|
|
85
100
|
getSetGlobalLocale(oldLocale);
|
|
86
101
|
} catch (e) {
|
|
87
102
|
// mark as not found to avoid repeating expensive file require call causing high CPU
|
|
88
103
|
// when trying to find en-US, en_US, en-us for every format call
|
|
89
|
-
locales[
|
|
104
|
+
locales[normalizedName] = null; // null means not found
|
|
90
105
|
}
|
|
91
106
|
}
|
|
92
|
-
|
|
107
|
+
if (hasOwnProp(locales, normalizedName)) {
|
|
108
|
+
return locales[normalizedName];
|
|
109
|
+
}
|
|
93
110
|
}
|
|
94
111
|
|
|
95
112
|
// This function will load locale and then set the global locale. If
|
|
@@ -175,17 +192,20 @@ export function defineLocale(name, config) {
|
|
|
175
192
|
}
|
|
176
193
|
|
|
177
194
|
export function updateLocale(name, config) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
parentConfig = baseConfig;
|
|
195
|
+
var locale,
|
|
196
|
+
tmpLocale = loadLocale(name),
|
|
197
|
+
parentConfig = baseConfig;
|
|
182
198
|
|
|
199
|
+
if (tmpLocale != null) {
|
|
200
|
+
name = tmpLocale._abbr;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (config != null) {
|
|
183
204
|
if (locales[name] != null && locales[name].parentLocale != null) {
|
|
184
205
|
// Update existing child locale in-place to avoid memory-leaks
|
|
185
206
|
locales[name].set(mergeConfigs(locales[name]._config, config));
|
|
186
207
|
} else {
|
|
187
208
|
// MERGE
|
|
188
|
-
tmpLocale = loadLocale(name);
|
|
189
209
|
if (tmpLocale != null) {
|
|
190
210
|
parentConfig = tmpLocale._config;
|
|
191
211
|
}
|
|
@@ -19,14 +19,37 @@ export var defaultRelativeTime = {
|
|
|
19
19
|
|
|
20
20
|
import isFunction from '../utils/is-function';
|
|
21
21
|
|
|
22
|
-
export function
|
|
22
|
+
export function relativeTimeWithoutPostformat(
|
|
23
|
+
number,
|
|
24
|
+
withoutSuffix,
|
|
25
|
+
string,
|
|
26
|
+
isFuture
|
|
27
|
+
) {
|
|
23
28
|
var output = this._relativeTime[string];
|
|
24
29
|
return isFunction(output)
|
|
25
30
|
? output(number, withoutSuffix, string, isFuture)
|
|
26
31
|
: output.replace(/%d/i, number);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
export function
|
|
34
|
+
export function relativeTime(number, withoutSuffix, string, isFuture) {
|
|
35
|
+
return this.postformat(
|
|
36
|
+
relativeTimeWithoutPostformat.call(
|
|
37
|
+
this,
|
|
38
|
+
number,
|
|
39
|
+
withoutSuffix,
|
|
40
|
+
string,
|
|
41
|
+
isFuture
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function pastFutureWithoutPostformat(diff, output) {
|
|
30
47
|
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
|
31
48
|
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
|
32
49
|
}
|
|
50
|
+
|
|
51
|
+
export function pastFuture(diff, output) {
|
|
52
|
+
return this.postformat(
|
|
53
|
+
pastFutureWithoutPostformat.call(this, diff, output)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -2,9 +2,13 @@ import isFunction from '../utils/is-function';
|
|
|
2
2
|
import extend from '../utils/extend';
|
|
3
3
|
import isObject from '../utils/is-object';
|
|
4
4
|
import hasOwnProp from '../utils/has-own-prop';
|
|
5
|
+
import { clearMonthsParseCache } from '../units/month';
|
|
6
|
+
import { clearWeekdaysParseCache } from '../units/day-of-week';
|
|
5
7
|
|
|
6
8
|
export function set(config) {
|
|
7
9
|
var prop, i;
|
|
10
|
+
clearMonthsParseCache(this, config);
|
|
11
|
+
clearWeekdaysParseCache(this, config);
|
|
8
12
|
for (i in config) {
|
|
9
13
|
if (hasOwnProp(config, i)) {
|
|
10
14
|
prop = config[i];
|
|
@@ -10,16 +10,16 @@ export function getCalendarFormat(myMoment, now) {
|
|
|
10
10
|
return diff < -6
|
|
11
11
|
? 'sameElse'
|
|
12
12
|
: diff < -1
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
? 'lastWeek'
|
|
14
|
+
: diff < 0
|
|
15
|
+
? 'lastDay'
|
|
16
|
+
: diff < 1
|
|
17
|
+
? 'sameDay'
|
|
18
|
+
: diff < 2
|
|
19
|
+
? 'nextDay'
|
|
20
|
+
: diff < 7
|
|
21
|
+
? 'nextWeek'
|
|
22
|
+
: 'sameElse';
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function calendar(time, formats) {
|