mol_time_all 1.1.12 → 1.1.13

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/web.esm.js CHANGED
@@ -1,625 +1,656 @@
1
+ "use strict";
1
2
  function require( path ){ return $node[ path ] };
2
3
  "use strict"
3
4
 
4
5
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
6
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
7
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
9
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9
10
  };
10
11
 
11
- var globalThis = globalThis || global || self || this
12
+ var globalThis = globalThis || ( typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this )
12
13
  var $ = ( typeof module === 'object' ) ? Object.setPrototypeOf( module['export'+'s'] , globalThis ) : globalThis
13
14
  $.$$ = $
14
- $.$mol = $ // deprecated
15
15
 
16
16
  ;
17
17
 
18
18
  var $node = $node || {}
19
- void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "../mol/" ) ] };
19
+ void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "../" ) ] };
20
20
  ;
21
- "use strict";
22
- Error.stackTraceLimit = Infinity;
23
- var $;
24
- (function ($) {
25
- })($ || ($ = {}));
26
- module.exports = $;
27
- //mol.js.map
21
+ "use strict";
22
+ Error.stackTraceLimit = 50;
23
+ var $;
24
+ (function ($) {
25
+ })($ || ($ = {}));
26
+ module.exports = $;
27
+ //mam.js.map
28
28
  ;
29
29
 
30
- $node[ "../mol/mol" ] = $node[ "../mol/mol.js" ] = module.exports }.call( {} , {} )
30
+ $node[ "../mam" ] = $node[ "../mam.js" ] = module.exports }.call( {} , {} )
31
31
  ;
32
- "use strict";
33
- var $;
34
- (function ($) {
35
- class $mol_time_base {
36
- static formatter(pattern) {
37
- if (this.patterns[pattern])
38
- return this.patterns[pattern];
39
- var tokens = Object.keys(this.patterns)
40
- .sort()
41
- .reverse()
42
- .map((token) => token.replace(/([-+*.\[\]()\^])/g, '\\$1'));
43
- var lexer = RegExp('(.*?)(' + tokens.join('|') + '|$)', 'g');
44
- var funcs = [];
45
- pattern.replace(lexer, (str, text, token) => {
46
- if (text)
47
- funcs.push(() => text);
48
- if (token)
49
- funcs.push(this.patterns[token]);
50
- return str;
51
- });
52
- return this.patterns[pattern] = (arg) => {
53
- return funcs.reduce((res, func) => res + func(arg), '');
54
- };
55
- }
56
- toString(pattern) {
57
- const Base = this.constructor;
58
- const formatter = Base.formatter(pattern);
59
- return formatter(this);
60
- }
61
- }
62
- $mol_time_base.patterns = {};
63
- $.$mol_time_base = $mol_time_base;
64
- })($ || ($ = {}));
32
+ "use strict";
33
+ var $;
34
+ (function ($) {
35
+ class $mol_time_base {
36
+ static patterns = {};
37
+ static formatter(pattern) {
38
+ if (this.patterns[pattern])
39
+ return this.patterns[pattern];
40
+ var tokens = Object.keys(this.patterns)
41
+ .sort()
42
+ .reverse()
43
+ .map((token) => token.replace(/([-+*.\[\]()\^])/g, '\\$1'));
44
+ var lexer = RegExp('(.*?)(' + tokens.join('|') + '|$)', 'g');
45
+ var funcs = [];
46
+ pattern.replace(lexer, (str, text, token) => {
47
+ if (text)
48
+ funcs.push(() => text);
49
+ if (token)
50
+ funcs.push(this.patterns[token]);
51
+ return str;
52
+ });
53
+ return this.patterns[pattern] = (arg) => {
54
+ return funcs.reduce((res, func) => res + func(arg), '');
55
+ };
56
+ }
57
+ toString(pattern) {
58
+ const Base = this.constructor;
59
+ const formatter = Base.formatter(pattern);
60
+ return formatter(this);
61
+ }
62
+ }
63
+ $.$mol_time_base = $mol_time_base;
64
+ })($ || ($ = {}));
65
65
  //base.js.map
66
66
  ;
67
- "use strict";
68
- var $;
69
- (function ($) {
70
- class $mol_time_duration extends $.$mol_time_base {
71
- constructor(config = 0) {
72
- super();
73
- this.year = 0;
74
- this.month = 0;
75
- this.day = 0;
76
- this.hour = 0;
77
- this.minute = 0;
78
- this.second = 0;
79
- if (typeof config === 'number') {
80
- this.second = config / 1000;
81
- return;
82
- }
83
- if (typeof config === 'string') {
84
- if (config === 'Z') {
85
- this.hour = 0;
86
- this.minute = 0;
87
- return;
88
- }
89
- duration: {
90
- const parser = /^P(?:([+-]?\d+(?:\.\d+)?)Y)?(?:([+-]?\d+(?:\.\d+)?)M)?(?:([+-]?\d+(?:\.\d+)?)D)?(?:T(?:([+-]?\d+(?:\.\d+)?)h)?(?:([+-]?\d+(?:\.\d+)?)m)?(?:([+-]?\d+(?:\.\d+)?)s)?)?$/i;
91
- const found = parser.exec(config);
92
- if (!found)
93
- break duration;
94
- if (found[1])
95
- this.year = Number(found[1]);
96
- if (found[2])
97
- this.month = Number(found[2]);
98
- if (found[3])
99
- this.day = Number(found[3]);
100
- if (found[4])
101
- this.hour = Number(found[4]);
102
- if (found[5])
103
- this.minute = Number(found[5]);
104
- if (found[6])
105
- this.second = Number(found[6]);
106
- return;
107
- }
108
- offset: {
109
- var parser = /^[+-](\d\d)(?::?(\d\d))?$/i;
110
- var found = parser.exec(config);
111
- if (!found)
112
- break offset;
113
- if (found[1])
114
- this.hour = Number(found[1]);
115
- if (found[2])
116
- this.minute = Number(found[2]);
117
- return;
118
- }
119
- throw new Error(`Can not parse time duration (${config})`);
120
- }
121
- this.year = config.year || 0;
122
- this.month = config.month || 0;
123
- this.day = config.day || 0;
124
- this.hour = config.hour || 0;
125
- this.minute = config.minute || 0;
126
- this.second = config.second || 0;
127
- }
128
- summ(config) {
129
- const duration = new $mol_time_duration(config);
130
- return new $mol_time_duration({
131
- year: this.year + duration.year,
132
- month: this.month + duration.month,
133
- day: this.day + duration.day,
134
- hour: this.hour + duration.hour,
135
- minute: this.minute + duration.minute,
136
- second: this.second + duration.second,
137
- });
138
- }
139
- mult(numb) {
140
- return new $mol_time_duration({
141
- year: this.year && this.year * numb,
142
- month: this.month && this.month * numb,
143
- day: this.day && this.day * numb,
144
- hour: this.hour && this.hour * numb,
145
- minute: this.minute && this.minute * numb,
146
- second: this.second && this.second * numb,
147
- });
148
- }
149
- count(config) {
150
- const duration = new $mol_time_duration(config);
151
- return this.valueOf() / duration.valueOf();
152
- }
153
- valueOf() {
154
- var day = this.year * 365 + this.month * 30.4 + this.day;
155
- var second = ((day * 24 + this.hour) * 60 + this.minute) * 60 + this.second;
156
- return second * 1000;
157
- }
158
- toJSON() { return this.toString(); }
159
- toString(pattern = 'P#Y#M#DT#h#m#s') {
160
- return super.toString(pattern);
161
- }
162
- }
163
- $mol_time_duration.patterns = {
164
- '#Y': (duration) => {
165
- if (!duration.year)
166
- return '';
167
- return duration.year + 'Y';
168
- },
169
- '#M': (duration) => {
170
- if (!duration.month)
171
- return '';
172
- return duration.month + 'M';
173
- },
174
- '#D': (duration) => {
175
- if (!duration.day)
176
- return '';
177
- return duration.day + 'D';
178
- },
179
- '#h': (duration) => {
180
- if (!duration.hour)
181
- return '';
182
- return duration.hour + 'H';
183
- },
184
- '#m': (duration) => {
185
- if (!duration.minute)
186
- return '';
187
- return duration.minute + 'M';
188
- },
189
- '#s': (duration) => {
190
- if (!duration.second)
191
- return '';
192
- return duration.second + 'S';
193
- },
194
- };
195
- $.$mol_time_duration = $mol_time_duration;
196
- })($ || ($ = {}));
67
+ "use strict";
68
+ var $;
69
+ (function ($) {
70
+ class $mol_time_duration extends $.$mol_time_base {
71
+ constructor(config = 0) {
72
+ super();
73
+ if (typeof config === 'number') {
74
+ this.second = config / 1000;
75
+ return;
76
+ }
77
+ if (typeof config === 'string') {
78
+ if (config === 'Z') {
79
+ this.hour = 0;
80
+ this.minute = 0;
81
+ return;
82
+ }
83
+ duration: {
84
+ const parser = /^P(?:([+-]?\d+(?:\.\d+)?)Y)?(?:([+-]?\d+(?:\.\d+)?)M)?(?:([+-]?\d+(?:\.\d+)?)D)?(?:T(?:([+-]?\d+(?:\.\d+)?)h)?(?:([+-]?\d+(?:\.\d+)?)m)?(?:([+-]?\d+(?:\.\d+)?)s)?)?$/i;
85
+ const found = parser.exec(config);
86
+ if (!found)
87
+ break duration;
88
+ if (found[1])
89
+ this.year = Number(found[1]);
90
+ if (found[2])
91
+ this.month = Number(found[2]);
92
+ if (found[3])
93
+ this.day = Number(found[3]);
94
+ if (found[4])
95
+ this.hour = Number(found[4]);
96
+ if (found[5])
97
+ this.minute = Number(found[5]);
98
+ if (found[6])
99
+ this.second = Number(found[6]);
100
+ return;
101
+ }
102
+ offset: {
103
+ var parser = /^[+-](\d\d)(?::?(\d\d))?$/i;
104
+ var found = parser.exec(config);
105
+ if (!found)
106
+ break offset;
107
+ if (found[1])
108
+ this.hour = Number(found[1]);
109
+ if (found[2])
110
+ this.minute = Number(found[2]);
111
+ return;
112
+ }
113
+ throw new Error(`Can not parse time duration (${config})`);
114
+ }
115
+ this.year = config.year || 0;
116
+ this.month = config.month || 0;
117
+ this.day = config.day || 0;
118
+ this.hour = config.hour || 0;
119
+ this.minute = config.minute || 0;
120
+ this.second = config.second || 0;
121
+ }
122
+ year = 0;
123
+ month = 0;
124
+ day = 0;
125
+ hour = 0;
126
+ minute = 0;
127
+ second = 0;
128
+ summ(config) {
129
+ const duration = new $mol_time_duration(config);
130
+ return new $mol_time_duration({
131
+ year: this.year + duration.year,
132
+ month: this.month + duration.month,
133
+ day: this.day + duration.day,
134
+ hour: this.hour + duration.hour,
135
+ minute: this.minute + duration.minute,
136
+ second: this.second + duration.second,
137
+ });
138
+ }
139
+ mult(numb) {
140
+ return new $mol_time_duration({
141
+ year: this.year && this.year * numb,
142
+ month: this.month && this.month * numb,
143
+ day: this.day && this.day * numb,
144
+ hour: this.hour && this.hour * numb,
145
+ minute: this.minute && this.minute * numb,
146
+ second: this.second && this.second * numb,
147
+ });
148
+ }
149
+ count(config) {
150
+ const duration = new $mol_time_duration(config);
151
+ return this.valueOf() / duration.valueOf();
152
+ }
153
+ valueOf() {
154
+ var day = this.year * 365 + this.month * 30.4 + this.day;
155
+ var second = ((day * 24 + this.hour) * 60 + this.minute) * 60 + this.second;
156
+ return second * 1000;
157
+ }
158
+ toJSON() { return this.toString(); }
159
+ toString(pattern = 'P#Y#M#DT#h#m#s') {
160
+ return super.toString(pattern);
161
+ }
162
+ static patterns = {
163
+ '#Y': (duration) => {
164
+ if (!duration.year)
165
+ return '';
166
+ return duration.year + 'Y';
167
+ },
168
+ '#M': (duration) => {
169
+ if (!duration.month)
170
+ return '';
171
+ return duration.month + 'M';
172
+ },
173
+ '#D': (duration) => {
174
+ if (!duration.day)
175
+ return '';
176
+ return duration.day + 'D';
177
+ },
178
+ '#h': (duration) => {
179
+ if (!duration.hour)
180
+ return '';
181
+ return duration.hour + 'H';
182
+ },
183
+ '#m': (duration) => {
184
+ if (!duration.minute)
185
+ return '';
186
+ return duration.minute + 'M';
187
+ },
188
+ '#s': (duration) => {
189
+ if (!duration.second)
190
+ return '';
191
+ return duration.second + 'S';
192
+ },
193
+ };
194
+ }
195
+ $.$mol_time_duration = $mol_time_duration;
196
+ })($ || ($ = {}));
197
197
  //duration.js.map
198
198
  ;
199
- "use strict";
200
- var $;
201
- (function ($) {
202
- class $mol_time_moment extends $.$mol_time_base {
203
- constructor(config = new Date) {
204
- super();
205
- if (typeof config === 'number')
206
- config = new Date(config);
207
- if (typeof config === 'string') {
208
- const parsed = /^(?:(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d))?)?)?(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d(?:\.\d+)?))?)?(Z|[\+\-]\d\d(?::?(?:\d\d)?)?)?)?$/.exec(config);
209
- if (!parsed)
210
- throw new Error(`Can not parse time moment (${config})`);
211
- if (parsed[1])
212
- this.year = Number(parsed[1]);
213
- if (parsed[2])
214
- this.month = Number(parsed[2]) - 1;
215
- if (parsed[3])
216
- this.day = Number(parsed[3]) - 1;
217
- if (parsed[4])
218
- this.hour = Number(parsed[4]);
219
- if (parsed[5])
220
- this.minute = Number(parsed[5]);
221
- if (parsed[6])
222
- this.second = Number(parsed[6]);
223
- if (parsed[7])
224
- this.offset = new $.$mol_time_duration(parsed[7]);
225
- return;
226
- }
227
- if (config instanceof Date) {
228
- this.year = config.getFullYear();
229
- this.month = config.getMonth();
230
- this.day = config.getDate() - 1;
231
- this.hour = config.getHours();
232
- this.minute = config.getMinutes();
233
- this.second = config.getSeconds() + config.getMilliseconds() / 1000;
234
- const offset = -config.getTimezoneOffset();
235
- this.offset = new $.$mol_time_duration({
236
- hour: (offset < 0) ? Math.ceil(offset / 60) : Math.floor(offset / 60),
237
- minute: offset % 60
238
- });
239
- return;
240
- }
241
- this.year = config.year;
242
- this.month = config.month;
243
- this.day = config.day;
244
- this.hour = config.hour;
245
- this.minute = config.minute;
246
- this.second = config.second;
247
- this.offset = config.offset == null ? config.offset : new $.$mol_time_duration(config.offset);
248
- }
249
- get weekday() {
250
- return (this.native.getDay() + 6) % 7;
251
- }
252
- get native() {
253
- var _a, _b, _c, _d, _e;
254
- if (this._native)
255
- return this._native;
256
- const utc = this.toOffset('Z');
257
- return this._native = new Date(Date.UTC((_a = utc.year) !== null && _a !== void 0 ? _a : 0, (_b = utc.month) !== null && _b !== void 0 ? _b : 0, ((_c = utc.day) !== null && _c !== void 0 ? _c : 0) + 1, (_d = utc.hour) !== null && _d !== void 0 ? _d : 0, (_e = utc.minute) !== null && _e !== void 0 ? _e : 0, utc.second != undefined ? Math.floor(utc.second) : 0, utc.second != undefined ? Math.floor((utc.second - Math.floor(utc.second)) * 1000) : 0));
258
- }
259
- get normal() {
260
- if (this._normal)
261
- return this._normal;
262
- const moment = new $mol_time_moment(this.native);
263
- return this._normal = new $mol_time_moment({
264
- year: this.year === undefined ? undefined : moment.year,
265
- month: this.month === undefined ? undefined : moment.month,
266
- day: this.day === undefined ? undefined : moment.day,
267
- hour: this.hour === undefined ? undefined : moment.hour,
268
- minute: this.minute === undefined ? undefined : moment.minute,
269
- second: this.second === undefined ? undefined : moment.second,
270
- offset: this.offset === undefined ? undefined : moment.offset,
271
- });
272
- }
273
- merge(config) {
274
- const moment = new $mol_time_moment(config);
275
- return new $mol_time_moment({
276
- year: moment.year === undefined ? this.year : moment.year,
277
- month: moment.month === undefined ? this.month : moment.month,
278
- day: moment.day === undefined ? this.day : moment.day,
279
- hour: moment.hour === undefined ? this.hour : moment.hour,
280
- minute: moment.minute === undefined ? this.minute : moment.minute,
281
- second: moment.second === undefined ? this.second : moment.second,
282
- offset: moment.offset === undefined ? this.offset : moment.offset,
283
- });
284
- }
285
- shift(config) {
286
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
287
- const duration = new $.$mol_time_duration(config);
288
- const moment = new $mol_time_moment().merge({
289
- year: this.year,
290
- month: this.month,
291
- day: this.day,
292
- hour: (_a = this.hour) !== null && _a !== void 0 ? _a : 0,
293
- minute: (_b = this.minute) !== null && _b !== void 0 ? _b : 0,
294
- second: (_c = this.second) !== null && _c !== void 0 ? _c : 0,
295
- offset: (_d = this.offset) !== null && _d !== void 0 ? _d : 0
296
- });
297
- const second = moment.second + ((_e = duration.second) !== null && _e !== void 0 ? _e : 0);
298
- const native = new Date(moment.year + ((_f = duration.year) !== null && _f !== void 0 ? _f : 0), moment.month + ((_g = duration.month) !== null && _g !== void 0 ? _g : 0), moment.day + 1 + ((_h = duration.day) !== null && _h !== void 0 ? _h : 0), moment.hour + ((_j = duration.hour) !== null && _j !== void 0 ? _j : 0), moment.minute + ((_k = duration.minute) !== null && _k !== void 0 ? _k : 0), Math.floor(second), (second - Math.floor(second)) * 1000);
299
- if (isNaN(native.valueOf()))
300
- throw new Error('Wrong time');
301
- return new $mol_time_moment({
302
- year: this.year === undefined ? undefined : native.getFullYear(),
303
- month: this.month === undefined ? undefined : native.getMonth(),
304
- day: this.day === undefined ? undefined : native.getDate() - 1,
305
- hour: this.hour === undefined ? undefined : native.getHours(),
306
- minute: this.minute === undefined ? undefined : native.getMinutes(),
307
- second: this.second === undefined ? undefined : native.getSeconds() + native.getMilliseconds() / 1000,
308
- offset: this.offset,
309
- });
310
- }
311
- mask(config) {
312
- const mask = new $mol_time_moment(config);
313
- return new $mol_time_moment({
314
- year: mask.year === undefined ? undefined : this.year,
315
- month: mask.month === undefined ? undefined : this.month,
316
- day: mask.day === undefined ? undefined : this.day,
317
- hour: mask.hour === undefined ? undefined : this.hour,
318
- minute: mask.minute === undefined ? undefined : this.minute,
319
- second: mask.second === undefined ? undefined : this.second,
320
- offset: mask.offset === undefined ? undefined : this.offset,
321
- });
322
- }
323
- toOffset(config) {
324
- if (this.hour === undefined)
325
- return this;
326
- if (this.minute === undefined)
327
- return this;
328
- if (this.second === undefined)
329
- return this;
330
- const duration = new $.$mol_time_duration(config);
331
- const offset = this.offset || new $mol_time_moment().offset;
332
- const moment = this.shift(duration.summ(offset.mult(-1)));
333
- return moment.merge({ offset: duration });
334
- }
335
- valueOf() { return this.native.getTime(); }
336
- toJSON() { return this.toString(); }
337
- toString(pattern = 'YYYY-MM-DDThh:mm:ss.sssZ') {
338
- return super.toString(pattern);
339
- }
340
- }
341
- $mol_time_moment.patterns = {
342
- 'YYYY': (moment) => {
343
- if (moment.year == null)
344
- return '';
345
- return String(moment.year);
346
- },
347
- 'AD': (moment) => {
348
- if (moment.year == null)
349
- return '';
350
- return String(Math.floor(moment.year / 100) + 1);
351
- },
352
- 'YY': (moment) => {
353
- if (moment.year == null)
354
- return '';
355
- return String(moment.year % 100);
356
- },
357
- 'Month': (pattern => (moment) => {
358
- if (moment.month == null)
359
- return '';
360
- return pattern.format(moment.native);
361
- })(new Intl.DateTimeFormat(undefined, { month: 'long' })),
362
- 'DD Month': (pattern => (moment) => {
363
- if (moment.month == null) {
364
- if (moment.day == null) {
365
- return '';
366
- }
367
- else {
368
- return $mol_time_moment.patterns['DD'](moment);
369
- }
370
- }
371
- else {
372
- if (moment.day == null) {
373
- return $mol_time_moment.patterns['Month'](moment);
374
- }
375
- else {
376
- return pattern.format(moment.native);
377
- }
378
- }
379
- })(new Intl.DateTimeFormat(undefined, { day: '2-digit', month: 'long' })),
380
- 'D Month': (pattern => (moment) => {
381
- if (moment.month == null) {
382
- if (moment.day == null) {
383
- return '';
384
- }
385
- else {
386
- return $mol_time_moment.patterns['D'](moment);
387
- }
388
- }
389
- else {
390
- if (moment.day == null) {
391
- return $mol_time_moment.patterns['Month'](moment);
392
- }
393
- else {
394
- return pattern.format(moment.native);
395
- }
396
- }
397
- })(new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'long' })),
398
- 'Mon': (pattern => (moment) => {
399
- if (moment.month == null)
400
- return '';
401
- return pattern.format(moment.native);
402
- })(new Intl.DateTimeFormat(undefined, { month: 'short' })),
403
- 'DD Mon': (pattern => (moment) => {
404
- if (moment.month == null) {
405
- if (moment.day == null) {
406
- return '';
407
- }
408
- else {
409
- return $mol_time_moment.patterns['DD'](moment);
410
- }
411
- }
412
- else {
413
- if (moment.day == null) {
414
- return $mol_time_moment.patterns['Mon'](moment);
415
- }
416
- else {
417
- return pattern.format(moment.native);
418
- }
419
- }
420
- })(new Intl.DateTimeFormat(undefined, { day: '2-digit', month: 'short' })),
421
- 'D Mon': (pattern => (moment) => {
422
- if (moment.month == null) {
423
- if (moment.day == null) {
424
- return '';
425
- }
426
- else {
427
- return $mol_time_moment.patterns['D'](moment);
428
- }
429
- }
430
- else {
431
- if (moment.day == null) {
432
- return $mol_time_moment.patterns['Mon'](moment);
433
- }
434
- else {
435
- return pattern.format(moment.native);
436
- }
437
- }
438
- })(new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'short' })),
439
- '-MM': (moment) => {
440
- if (moment.month == null)
441
- return '';
442
- return '-' + $mol_time_moment.patterns['MM'](moment);
443
- },
444
- 'MM': (moment) => {
445
- if (moment.month == null)
446
- return '';
447
- return String(100 + moment.month + 1).slice(1);
448
- },
449
- 'M': (moment) => {
450
- if (moment.month == null)
451
- return '';
452
- return String(moment.month + 1);
453
- },
454
- 'WeekDay': (pattern => (moment) => {
455
- if (moment.day == null)
456
- return '';
457
- if (moment.month == null)
458
- return '';
459
- if (moment.year == null)
460
- return '';
461
- return pattern.format(moment.native);
462
- })(new Intl.DateTimeFormat(undefined, { weekday: 'long' })),
463
- 'WD': (pattern => (moment) => {
464
- if (moment.day == null)
465
- return '';
466
- if (moment.month == null)
467
- return '';
468
- if (moment.year == null)
469
- return '';
470
- return pattern.format(moment.native);
471
- })(new Intl.DateTimeFormat(undefined, { weekday: 'short' })),
472
- '-DD': (moment) => {
473
- if (moment.day == null)
474
- return '';
475
- return '-' + $mol_time_moment.patterns['DD'](moment);
476
- },
477
- 'DD': (moment) => {
478
- if (moment.day == null)
479
- return '';
480
- return String(100 + moment.day + 1).slice(1);
481
- },
482
- 'D': (moment) => {
483
- if (moment.day == null)
484
- return '';
485
- return String(moment.day + 1);
486
- },
487
- 'Thh': (moment) => {
488
- if (moment.hour == null)
489
- return '';
490
- return 'T' + $mol_time_moment.patterns['hh'](moment);
491
- },
492
- 'hh': (moment) => {
493
- if (moment.hour == null)
494
- return '';
495
- return String(100 + moment.hour).slice(1);
496
- },
497
- 'h': (moment) => {
498
- if (moment.hour == null)
499
- return '';
500
- return String(moment.hour);
501
- },
502
- ':mm': (moment) => {
503
- if (moment.minute == null)
504
- return '';
505
- return ':' + $mol_time_moment.patterns['mm'](moment);
506
- },
507
- 'mm': (moment) => {
508
- if (moment.minute == null)
509
- return '';
510
- return String(100 + moment.minute).slice(1);
511
- },
512
- 'm': (moment) => {
513
- if (moment.minute == null)
514
- return '';
515
- return String(moment.minute);
516
- },
517
- ':ss': (moment) => {
518
- if (moment.second == null)
519
- return '';
520
- return ':' + $mol_time_moment.patterns['ss'](moment);
521
- },
522
- 'ss': (moment) => {
523
- if (moment.second == null)
524
- return '';
525
- return String(100 + moment.second | 0).slice(1);
526
- },
527
- 's': (moment) => {
528
- if (moment.second == null)
529
- return '';
530
- return String(moment.second | 0);
531
- },
532
- '.sss': (moment) => {
533
- if (moment.second == null)
534
- return '';
535
- if (moment.second === (moment.second | 0))
536
- return '';
537
- return '.' + $mol_time_moment.patterns['sss'](moment);
538
- },
539
- 'sss': (moment) => {
540
- if (moment.second == null)
541
- return '';
542
- const millisecond = Math.floor((moment.second - Math.floor(moment.second)) * 1000);
543
- return String(1000 + millisecond).slice(1);
544
- },
545
- 'Z': (moment) => {
546
- const offset = moment.offset;
547
- if (!offset)
548
- return '';
549
- let hour = offset.hour;
550
- let sign = '+';
551
- if (hour < 0) {
552
- sign = '-';
553
- hour = -hour;
554
- }
555
- return sign + String(100 + hour).slice(1) + ':' + String(100 + offset.minute).slice(1);
556
- }
557
- };
558
- $.$mol_time_moment = $mol_time_moment;
559
- })($ || ($ = {}));
199
+ "use strict";
200
+ var $;
201
+ (function ($) {
202
+ function $mol_fail(error) {
203
+ throw error;
204
+ }
205
+ $.$mol_fail = $mol_fail;
206
+ })($ || ($ = {}));
207
+ //fail.js.map
208
+ ;
209
+ "use strict";
210
+ var $;
211
+ (function ($) {
212
+ let $mol_time_moment_weekdays;
213
+ (function ($mol_time_moment_weekdays) {
214
+ $mol_time_moment_weekdays[$mol_time_moment_weekdays["monday"] = 0] = "monday";
215
+ $mol_time_moment_weekdays[$mol_time_moment_weekdays["tuesday"] = 1] = "tuesday";
216
+ $mol_time_moment_weekdays[$mol_time_moment_weekdays["wednesday"] = 2] = "wednesday";
217
+ $mol_time_moment_weekdays[$mol_time_moment_weekdays["thursday"] = 3] = "thursday";
218
+ $mol_time_moment_weekdays[$mol_time_moment_weekdays["friday"] = 4] = "friday";
219
+ $mol_time_moment_weekdays[$mol_time_moment_weekdays["saturday"] = 5] = "saturday";
220
+ $mol_time_moment_weekdays[$mol_time_moment_weekdays["sunday"] = 6] = "sunday";
221
+ })($mol_time_moment_weekdays = $.$mol_time_moment_weekdays || ($.$mol_time_moment_weekdays = {}));
222
+ function numb(str, max) {
223
+ const numb = Number(str);
224
+ if (numb < max)
225
+ return numb;
226
+ $.$mol_fail(new Error(`Wrong time component ${str}`));
227
+ }
228
+ class $mol_time_moment extends $.$mol_time_base {
229
+ constructor(config = new Date) {
230
+ super();
231
+ if (typeof config === 'number')
232
+ config = new Date(config);
233
+ if (typeof config === 'string') {
234
+ const parsed = /^(?:(\d\d?\d?\d?)(?:-?(\d\d?)(?:-?(\d\d?))?)?)?(?:[T ](?:(\d\d?)(?::?(\d\d?)(?::?(\d\d?(?:\.\d+)?))?)?)?(Z|[\+\-]\d\d?(?::?(?:\d\d?)?)?)?)?$/.exec(config);
235
+ if (!parsed)
236
+ throw new Error(`Can not parse time moment (${config})`);
237
+ if (parsed[1])
238
+ this.year = numb(parsed[1], 9999);
239
+ if (parsed[2])
240
+ this.month = numb(parsed[2], 13) - 1;
241
+ if (parsed[3])
242
+ this.day = numb(parsed[3], 32) - 1;
243
+ if (parsed[4])
244
+ this.hour = numb(parsed[4], 60);
245
+ if (parsed[5])
246
+ this.minute = numb(parsed[5], 60);
247
+ if (parsed[6])
248
+ this.second = numb(parsed[6], 60);
249
+ if (parsed[7])
250
+ this.offset = new $.$mol_time_duration(parsed[7]);
251
+ return;
252
+ }
253
+ if (config instanceof Date) {
254
+ this.year = config.getFullYear();
255
+ this.month = config.getMonth();
256
+ this.day = config.getDate() - 1;
257
+ this.hour = config.getHours();
258
+ this.minute = config.getMinutes();
259
+ this.second = config.getSeconds() + config.getMilliseconds() / 1000;
260
+ const offset = -config.getTimezoneOffset();
261
+ this.offset = new $.$mol_time_duration({
262
+ hour: (offset < 0) ? Math.ceil(offset / 60) : Math.floor(offset / 60),
263
+ minute: offset % 60
264
+ });
265
+ return;
266
+ }
267
+ this.year = config.year;
268
+ this.month = config.month;
269
+ this.day = config.day;
270
+ this.hour = config.hour;
271
+ this.minute = config.minute;
272
+ this.second = config.second;
273
+ this.offset = config.offset == null ? config.offset : new $.$mol_time_duration(config.offset);
274
+ }
275
+ year;
276
+ month;
277
+ day;
278
+ hour;
279
+ minute;
280
+ second;
281
+ offset;
282
+ get weekday() {
283
+ return (this.native.getDay() + 6) % 7;
284
+ }
285
+ _native;
286
+ get native() {
287
+ if (this._native)
288
+ return this._native;
289
+ const utc = this.toOffset('Z');
290
+ return this._native = new Date(Date.UTC(utc.year ?? 0, utc.month ?? 0, (utc.day ?? 0) + 1, utc.hour ?? 0, utc.minute ?? 0, utc.second != undefined ? Math.floor(utc.second) : 0, utc.second != undefined ? Math.floor((utc.second - Math.floor(utc.second)) * 1000) : 0));
291
+ }
292
+ _normal;
293
+ get normal() {
294
+ if (this._normal)
295
+ return this._normal;
296
+ const moment = new $mol_time_moment(this.native);
297
+ return this._normal = new $mol_time_moment({
298
+ year: this.year === undefined ? undefined : moment.year,
299
+ month: this.month === undefined ? undefined : moment.month,
300
+ day: this.day === undefined ? undefined : moment.day,
301
+ hour: this.hour === undefined ? undefined : moment.hour,
302
+ minute: this.minute === undefined ? undefined : moment.minute,
303
+ second: this.second === undefined ? undefined : moment.second,
304
+ offset: this.offset === undefined ? undefined : moment.offset,
305
+ });
306
+ }
307
+ merge(config) {
308
+ const moment = new $mol_time_moment(config);
309
+ return new $mol_time_moment({
310
+ year: moment.year === undefined ? this.year : moment.year,
311
+ month: moment.month === undefined ? this.month : moment.month,
312
+ day: moment.day === undefined ? this.day : moment.day,
313
+ hour: moment.hour === undefined ? this.hour : moment.hour,
314
+ minute: moment.minute === undefined ? this.minute : moment.minute,
315
+ second: moment.second === undefined ? this.second : moment.second,
316
+ offset: moment.offset === undefined ? this.offset : moment.offset,
317
+ });
318
+ }
319
+ shift(config) {
320
+ const duration = new $.$mol_time_duration(config);
321
+ const moment = new $mol_time_moment().merge({
322
+ year: this.year,
323
+ month: this.month,
324
+ day: this.day,
325
+ hour: this.hour ?? 0,
326
+ minute: this.minute ?? 0,
327
+ second: this.second ?? 0,
328
+ offset: this.offset ?? 0
329
+ });
330
+ const second = moment.second + (duration.second ?? 0);
331
+ const native = new Date(moment.year + (duration.year ?? 0), moment.month + (duration.month ?? 0), moment.day + 1 + (duration.day ?? 0), moment.hour + (duration.hour ?? 0), moment.minute + (duration.minute ?? 0), Math.floor(second), (second - Math.floor(second)) * 1000);
332
+ if (isNaN(native.valueOf()))
333
+ throw new Error('Wrong time');
334
+ return new $mol_time_moment({
335
+ year: this.year === undefined ? undefined : native.getFullYear(),
336
+ month: this.month === undefined ? undefined : native.getMonth(),
337
+ day: this.day === undefined ? undefined : native.getDate() - 1,
338
+ hour: this.hour === undefined ? undefined : native.getHours(),
339
+ minute: this.minute === undefined ? undefined : native.getMinutes(),
340
+ second: this.second === undefined ? undefined : native.getSeconds() + native.getMilliseconds() / 1000,
341
+ offset: this.offset,
342
+ });
343
+ }
344
+ mask(config) {
345
+ const mask = new $mol_time_moment(config);
346
+ return new $mol_time_moment({
347
+ year: mask.year === undefined ? undefined : this.year,
348
+ month: mask.month === undefined ? undefined : this.month,
349
+ day: mask.day === undefined ? undefined : this.day,
350
+ hour: mask.hour === undefined ? undefined : this.hour,
351
+ minute: mask.minute === undefined ? undefined : this.minute,
352
+ second: mask.second === undefined ? undefined : this.second,
353
+ offset: mask.offset === undefined ? undefined : this.offset,
354
+ });
355
+ }
356
+ toOffset(config) {
357
+ const duration = new $.$mol_time_duration(config);
358
+ const offset = this.offset || new $mol_time_moment().offset;
359
+ let with_time = new $mol_time_moment('T00:00:00').merge(this);
360
+ const moment = with_time.shift(duration.summ(offset.mult(-1)));
361
+ return moment.merge({ offset: duration });
362
+ }
363
+ valueOf() { return this.native.getTime(); }
364
+ toJSON() { return this.toString(); }
365
+ toString(pattern = 'YYYY-MM-DDThh:mm:ss.sssZ') {
366
+ return super.toString(pattern);
367
+ }
368
+ static patterns = {
369
+ 'YYYY': (moment) => {
370
+ if (moment.year == null)
371
+ return '';
372
+ return String(moment.year);
373
+ },
374
+ 'AD': (moment) => {
375
+ if (moment.year == null)
376
+ return '';
377
+ return String(Math.floor(moment.year / 100) + 1);
378
+ },
379
+ 'YY': (moment) => {
380
+ if (moment.year == null)
381
+ return '';
382
+ return String(moment.year % 100);
383
+ },
384
+ 'Month': (pattern => (moment) => {
385
+ if (moment.month == null)
386
+ return '';
387
+ return pattern.format(moment.native);
388
+ })(new Intl.DateTimeFormat(undefined, { month: 'long' })),
389
+ 'DD Month': (pattern => (moment) => {
390
+ if (moment.month == null) {
391
+ if (moment.day == null) {
392
+ return '';
393
+ }
394
+ else {
395
+ return $mol_time_moment.patterns['DD'](moment);
396
+ }
397
+ }
398
+ else {
399
+ if (moment.day == null) {
400
+ return $mol_time_moment.patterns['Month'](moment);
401
+ }
402
+ else {
403
+ return pattern.format(moment.native);
404
+ }
405
+ }
406
+ })(new Intl.DateTimeFormat(undefined, { day: '2-digit', month: 'long' })),
407
+ 'D Month': (pattern => (moment) => {
408
+ if (moment.month == null) {
409
+ if (moment.day == null) {
410
+ return '';
411
+ }
412
+ else {
413
+ return $mol_time_moment.patterns['D'](moment);
414
+ }
415
+ }
416
+ else {
417
+ if (moment.day == null) {
418
+ return $mol_time_moment.patterns['Month'](moment);
419
+ }
420
+ else {
421
+ return pattern.format(moment.native);
422
+ }
423
+ }
424
+ })(new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'long' })),
425
+ 'Mon': (pattern => (moment) => {
426
+ if (moment.month == null)
427
+ return '';
428
+ return pattern.format(moment.native);
429
+ })(new Intl.DateTimeFormat(undefined, { month: 'short' })),
430
+ 'DD Mon': (pattern => (moment) => {
431
+ if (moment.month == null) {
432
+ if (moment.day == null) {
433
+ return '';
434
+ }
435
+ else {
436
+ return $mol_time_moment.patterns['DD'](moment);
437
+ }
438
+ }
439
+ else {
440
+ if (moment.day == null) {
441
+ return $mol_time_moment.patterns['Mon'](moment);
442
+ }
443
+ else {
444
+ return pattern.format(moment.native);
445
+ }
446
+ }
447
+ })(new Intl.DateTimeFormat(undefined, { day: '2-digit', month: 'short' })),
448
+ 'D Mon': (pattern => (moment) => {
449
+ if (moment.month == null) {
450
+ if (moment.day == null) {
451
+ return '';
452
+ }
453
+ else {
454
+ return $mol_time_moment.patterns['D'](moment);
455
+ }
456
+ }
457
+ else {
458
+ if (moment.day == null) {
459
+ return $mol_time_moment.patterns['Mon'](moment);
460
+ }
461
+ else {
462
+ return pattern.format(moment.native);
463
+ }
464
+ }
465
+ })(new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'short' })),
466
+ '-MM': (moment) => {
467
+ if (moment.month == null)
468
+ return '';
469
+ return '-' + $mol_time_moment.patterns['MM'](moment);
470
+ },
471
+ 'MM': (moment) => {
472
+ if (moment.month == null)
473
+ return '';
474
+ return String(100 + moment.month + 1).slice(1);
475
+ },
476
+ 'M': (moment) => {
477
+ if (moment.month == null)
478
+ return '';
479
+ return String(moment.month + 1);
480
+ },
481
+ 'WeekDay': (pattern => (moment) => {
482
+ if (moment.day == null)
483
+ return '';
484
+ if (moment.month == null)
485
+ return '';
486
+ if (moment.year == null)
487
+ return '';
488
+ return pattern.format(moment.native);
489
+ })(new Intl.DateTimeFormat(undefined, { weekday: 'long' })),
490
+ 'WD': (pattern => (moment) => {
491
+ if (moment.day == null)
492
+ return '';
493
+ if (moment.month == null)
494
+ return '';
495
+ if (moment.year == null)
496
+ return '';
497
+ return pattern.format(moment.native);
498
+ })(new Intl.DateTimeFormat(undefined, { weekday: 'short' })),
499
+ '-DD': (moment) => {
500
+ if (moment.day == null)
501
+ return '';
502
+ return '-' + $mol_time_moment.patterns['DD'](moment);
503
+ },
504
+ 'DD': (moment) => {
505
+ if (moment.day == null)
506
+ return '';
507
+ return String(100 + moment.day + 1).slice(1);
508
+ },
509
+ 'D': (moment) => {
510
+ if (moment.day == null)
511
+ return '';
512
+ return String(moment.day + 1);
513
+ },
514
+ 'Thh': (moment) => {
515
+ if (moment.hour == null)
516
+ return '';
517
+ return 'T' + $mol_time_moment.patterns['hh'](moment);
518
+ },
519
+ 'hh': (moment) => {
520
+ if (moment.hour == null)
521
+ return '';
522
+ return String(100 + moment.hour).slice(1);
523
+ },
524
+ 'h': (moment) => {
525
+ if (moment.hour == null)
526
+ return '';
527
+ return String(moment.hour);
528
+ },
529
+ ':mm': (moment) => {
530
+ if (moment.minute == null)
531
+ return '';
532
+ return ':' + $mol_time_moment.patterns['mm'](moment);
533
+ },
534
+ 'mm': (moment) => {
535
+ if (moment.minute == null)
536
+ return '';
537
+ return String(100 + moment.minute).slice(1);
538
+ },
539
+ 'm': (moment) => {
540
+ if (moment.minute == null)
541
+ return '';
542
+ return String(moment.minute);
543
+ },
544
+ ':ss': (moment) => {
545
+ if (moment.second == null)
546
+ return '';
547
+ return ':' + $mol_time_moment.patterns['ss'](moment);
548
+ },
549
+ 'ss': (moment) => {
550
+ if (moment.second == null)
551
+ return '';
552
+ return String(100 + moment.second | 0).slice(1);
553
+ },
554
+ 's': (moment) => {
555
+ if (moment.second == null)
556
+ return '';
557
+ return String(moment.second | 0);
558
+ },
559
+ '.sss': (moment) => {
560
+ if (moment.second == null)
561
+ return '';
562
+ if (moment.second === (moment.second | 0))
563
+ return '';
564
+ return '.' + $mol_time_moment.patterns['sss'](moment);
565
+ },
566
+ 'sss': (moment) => {
567
+ if (moment.second == null)
568
+ return '';
569
+ const millisecond = Math.floor((moment.second - Math.floor(moment.second)) * 1000);
570
+ return String(1000 + millisecond).slice(1);
571
+ },
572
+ 'Z': (moment) => {
573
+ const offset = moment.offset;
574
+ if (!offset)
575
+ return '';
576
+ let hour = offset.hour;
577
+ let sign = '+';
578
+ if (hour < 0) {
579
+ sign = '-';
580
+ hour = -hour;
581
+ }
582
+ return sign + String(100 + hour).slice(1) + ':' + String(100 + offset.minute).slice(1);
583
+ }
584
+ };
585
+ }
586
+ $.$mol_time_moment = $mol_time_moment;
587
+ })($ || ($ = {}));
560
588
  //moment.js.map
561
589
  ;
562
- "use strict";
563
- var $;
564
- (function ($) {
565
- class $mol_time_interval extends $.$mol_time_base {
566
- constructor(config) {
567
- super();
568
- if (typeof config === 'string') {
569
- var chunks = config.split('/');
570
- if (chunks[0]) {
571
- if (chunks[0][0].toUpperCase() === 'P') {
572
- this._duration = new $.$mol_time_duration(chunks[0]);
573
- }
574
- else {
575
- this._start = new $.$mol_time_moment(chunks[0]);
576
- }
577
- }
578
- else {
579
- this._start = new $.$mol_time_moment();
580
- }
581
- if (chunks[1]) {
582
- if (chunks[1][0].toUpperCase() === 'P') {
583
- this._duration = new $.$mol_time_duration(chunks[1]);
584
- }
585
- else {
586
- this._end = new $.$mol_time_moment(chunks[1]);
587
- }
588
- }
589
- else {
590
- this._end = new $.$mol_time_moment();
591
- }
592
- return;
593
- }
594
- if (config.start !== undefined)
595
- this._start = new $.$mol_time_moment(config.start);
596
- if (config.end !== undefined)
597
- this._end = new $.$mol_time_moment(config.end);
598
- if (config.duration !== undefined)
599
- this._duration = new $.$mol_time_duration(config.duration);
600
- }
601
- get start() {
602
- if (this._start)
603
- return this._start;
604
- return this._start = this._end.shift(this._duration.mult(-1));
605
- }
606
- get end() {
607
- if (this._end)
608
- return this._end;
609
- return this._end = this._start.shift(this._duration);
610
- }
611
- get duration() {
612
- if (this._duration)
613
- return this._duration;
614
- return this._duration = new $.$mol_time_duration(this._end.valueOf() - this._start.valueOf());
615
- }
616
- toJSON() { return this.toString(); }
617
- toString() {
618
- return (this._start || this._duration || '').toString() + '/' + (this._end || this._duration || '').toString();
619
- }
620
- }
621
- $.$mol_time_interval = $mol_time_interval;
622
- })($ || ($ = {}));
590
+ "use strict";
591
+ var $;
592
+ (function ($) {
593
+ class $mol_time_interval extends $.$mol_time_base {
594
+ constructor(config) {
595
+ super();
596
+ if (typeof config === 'string') {
597
+ var chunks = config.split('/');
598
+ if (chunks[0]) {
599
+ if (chunks[0][0].toUpperCase() === 'P') {
600
+ this._duration = new $.$mol_time_duration(chunks[0]);
601
+ }
602
+ else {
603
+ this._start = new $.$mol_time_moment(chunks[0]);
604
+ }
605
+ }
606
+ else {
607
+ this._start = new $.$mol_time_moment();
608
+ }
609
+ if (chunks[1]) {
610
+ if (chunks[1][0].toUpperCase() === 'P') {
611
+ this._duration = new $.$mol_time_duration(chunks[1]);
612
+ }
613
+ else {
614
+ this._end = new $.$mol_time_moment(chunks[1]);
615
+ }
616
+ }
617
+ else {
618
+ this._end = new $.$mol_time_moment();
619
+ }
620
+ return;
621
+ }
622
+ if (config.start !== undefined)
623
+ this._start = new $.$mol_time_moment(config.start);
624
+ if (config.end !== undefined)
625
+ this._end = new $.$mol_time_moment(config.end);
626
+ if (config.duration !== undefined)
627
+ this._duration = new $.$mol_time_duration(config.duration);
628
+ }
629
+ _start;
630
+ get start() {
631
+ if (this._start)
632
+ return this._start;
633
+ return this._start = this._end.shift(this._duration.mult(-1));
634
+ }
635
+ _end;
636
+ get end() {
637
+ if (this._end)
638
+ return this._end;
639
+ return this._end = this._start.shift(this._duration);
640
+ }
641
+ _duration;
642
+ get duration() {
643
+ if (this._duration)
644
+ return this._duration;
645
+ return this._duration = new $.$mol_time_duration(this._end.valueOf() - this._start.valueOf());
646
+ }
647
+ toJSON() { return this.toString(); }
648
+ toString() {
649
+ return (this._start || this._duration || '').toString() + '/' + (this._end || this._duration || '').toString();
650
+ }
651
+ }
652
+ $.$mol_time_interval = $mol_time_interval;
653
+ })($ || ($ = {}));
623
654
  //interval.js.map
624
655
  ;
625
656
  export default $