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