@taiga-ui/cdk 2.26.0 → 2.29.0
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/README.md +4 -5
- package/abstract/control.d.ts +1 -1
- package/abstract/interactive.d.ts +4 -4
- package/abstract/taiga-ui-cdk-abstract.metadata.json +1 -1
- package/bundles/taiga-ui-cdk-abstract.umd.js +3 -3
- package/bundles/taiga-ui-cdk-abstract.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-abstract.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-abstract.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-date-time.umd.js +366 -287
- package/bundles/taiga-ui-cdk-date-time.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-date-time.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-date-time.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.js +276 -0
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.js.map +1 -0
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.min.js +16 -0
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.min.js.map +1 -0
- package/bundles/taiga-ui-cdk-directives-for.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-for.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.js +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-services.umd.js +4 -4
- package/bundles/taiga-ui-cdk-services.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-services.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-services.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-tokens.umd.js +5 -0
- package/bundles/taiga-ui-cdk-tokens.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-tokens.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-tokens.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js +4 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.min.js.map +1 -1
- package/date-time/date-separator.d.ts +2 -0
- package/date-time/day-range.d.ts +24 -12
- package/date-time/day.d.ts +71 -58
- package/date-time/index.d.ts +1 -0
- package/date-time/month-range.d.ts +1 -1
- package/date-time/month.d.ts +26 -26
- package/date-time/taiga-ui-cdk-date-time.metadata.json +1 -1
- package/date-time/time.d.ts +12 -12
- package/date-time/year.d.ts +27 -27
- package/directives/copy-processor/copy-processor.directive.d.ts +7 -0
- package/directives/copy-processor/copy-processor.module.d.ts +2 -0
- package/directives/copy-processor/index.d.ts +2 -0
- package/directives/copy-processor/package.json +13 -0
- package/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.d.ts +4 -0
- package/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.metadata.json +1 -0
- package/directives/for/for.directive.d.ts +1 -1
- package/directives/for/taiga-ui-cdk-directives-for.metadata.json +1 -1
- package/directives/media/media.directive.d.ts +1 -1
- package/directives/media/taiga-ui-cdk-directives-media.metadata.json +1 -1
- package/esm2015/abstract/control.js +1 -1
- package/esm2015/abstract/interactive.js +4 -4
- package/esm2015/date-time/date-separator.js +5 -0
- package/esm2015/date-time/day-range.js +46 -23
- package/esm2015/date-time/day.js +164 -122
- package/esm2015/date-time/index.js +2 -1
- package/esm2015/date-time/month-range.js +6 -6
- package/esm2015/date-time/month.js +56 -56
- package/esm2015/date-time/time.js +40 -40
- package/esm2015/date-time/year.js +49 -49
- package/esm2015/directives/copy-processor/copy-processor.directive.js +37 -0
- package/esm2015/directives/copy-processor/copy-processor.module.js +13 -0
- package/esm2015/directives/copy-processor/index.js +3 -0
- package/esm2015/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.js +5 -0
- package/esm2015/directives/for/for.directive.js +1 -1
- package/esm2015/directives/media/media.directive.js +2 -2
- package/esm2015/services/destroy.service.js +6 -3
- package/esm2015/services/obscured.service.js +1 -1
- package/esm2015/services/pan.service.js +3 -3
- package/esm2015/services/static-request.service.js +1 -1
- package/esm2015/tokens/index.js +2 -1
- package/esm2015/tokens/touch-supported.js +6 -0
- package/esm2015/utils/miscellaneous/ease-in-out-quad.js +2 -2
- package/esm2015/utils/miscellaneous/identity.js +4 -1
- package/esm5/abstract/control.js +1 -1
- package/esm5/abstract/interactive.js +4 -4
- package/esm5/date-time/date-separator.js +5 -0
- package/esm5/date-time/day-range.js +51 -23
- package/esm5/date-time/day.js +168 -122
- package/esm5/date-time/index.js +2 -1
- package/esm5/date-time/month-range.js +6 -6
- package/esm5/date-time/month.js +56 -56
- package/esm5/date-time/time.js +41 -41
- package/esm5/date-time/year.js +49 -49
- package/esm5/directives/copy-processor/copy-processor.directive.js +38 -0
- package/esm5/directives/copy-processor/copy-processor.module.js +16 -0
- package/esm5/directives/copy-processor/index.js +3 -0
- package/esm5/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.js +5 -0
- package/esm5/directives/for/for.directive.js +1 -1
- package/esm5/directives/media/media.directive.js +2 -2
- package/esm5/services/destroy.service.js +4 -4
- package/esm5/services/obscured.service.js +1 -1
- package/esm5/services/pan.service.js +3 -3
- package/esm5/services/static-request.service.js +1 -1
- package/esm5/tokens/index.js +2 -1
- package/esm5/tokens/touch-supported.js +6 -0
- package/esm5/utils/miscellaneous/ease-in-out-quad.js +2 -2
- package/esm5/utils/miscellaneous/identity.js +4 -1
- package/fesm2015/taiga-ui-cdk-abstract.js +3 -3
- package/fesm2015/taiga-ui-cdk-abstract.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-date-time.js +343 -275
- package/fesm2015/taiga-ui-cdk-date-time.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-copy-processor.js +52 -0
- package/fesm2015/taiga-ui-cdk-directives-copy-processor.js.map +1 -0
- package/fesm2015/taiga-ui-cdk-directives-for.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-media.js +1 -1
- package/fesm2015/taiga-ui-cdk-directives-media.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-services.js +7 -4
- package/fesm2015/taiga-ui-cdk-services.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-tokens.js +5 -1
- package/fesm2015/taiga-ui-cdk-tokens.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js +4 -1
- package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
- package/fesm5/taiga-ui-cdk-abstract.js +3 -3
- package/fesm5/taiga-ui-cdk-abstract.js.map +1 -1
- package/fesm5/taiga-ui-cdk-date-time.js +364 -287
- package/fesm5/taiga-ui-cdk-date-time.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-copy-processor.js +56 -0
- package/fesm5/taiga-ui-cdk-directives-copy-processor.js.map +1 -0
- package/fesm5/taiga-ui-cdk-directives-for.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-media.js +1 -1
- package/fesm5/taiga-ui-cdk-directives-media.js.map +1 -1
- package/fesm5/taiga-ui-cdk-services.js +5 -5
- package/fesm5/taiga-ui-cdk-services.js.map +1 -1
- package/fesm5/taiga-ui-cdk-tokens.js +5 -1
- package/fesm5/taiga-ui-cdk-tokens.js.map +1 -1
- package/fesm5/taiga-ui-cdk-utils-miscellaneous.js +4 -1
- package/fesm5/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
- package/package.json +4 -4
- package/services/destroy.service.d.ts +3 -2
- package/services/obscured.service.d.ts +1 -1
- package/services/static-request.service.d.ts +1 -1
- package/services/taiga-ui-cdk-services.metadata.json +1 -1
- package/tokens/index.d.ts +1 -0
- package/tokens/taiga-ui-cdk-tokens.metadata.json +1 -1
- package/tokens/touch-supported.d.ts +2 -0
- package/utils/miscellaneous/identity.d.ts +3 -0
|
@@ -61,6 +61,10 @@ var TUI_DATE_FORMAT = new InjectionToken('Active date format for Taiga UI', {
|
|
|
61
61
|
factory: function () { return 'DMY'; },
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
var TUI_DATE_SEPARATOR = new InjectionToken('Date separator for Taiga UI components', {
|
|
65
|
+
factory: function () { return '.'; },
|
|
66
|
+
});
|
|
67
|
+
|
|
64
68
|
/**
|
|
65
69
|
* Immutable year object
|
|
66
70
|
* @nosideeffects
|
|
@@ -70,6 +74,54 @@ var TuiYear = /** @class */ (function () {
|
|
|
70
74
|
this.year = year;
|
|
71
75
|
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
72
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Checks year for validity
|
|
79
|
+
*/
|
|
80
|
+
TuiYear.isValidYear = function (year) {
|
|
81
|
+
return Number.isInteger(year) && inRange(year, MIN_YEAR, MAX_YEAR + 1);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Check if passed year is a leap year
|
|
85
|
+
*/
|
|
86
|
+
TuiYear.isLeapYear = function (year) {
|
|
87
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
88
|
+
return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Returns amount of leap years from year 0 to the passed one
|
|
92
|
+
*/
|
|
93
|
+
TuiYear.getAbsoluteLeapYears = function (year) {
|
|
94
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
95
|
+
return Math.ceil(year / 400) + (Math.ceil(year / 4) - Math.ceil(year / 100));
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated DONT USE IT (will be deleted soon)
|
|
99
|
+
*
|
|
100
|
+
* Returns day of week offset of the beginning of the passed year
|
|
101
|
+
*
|
|
102
|
+
* @param year
|
|
103
|
+
* @param absoluteLeapYears amount of leap years prior to the passed one
|
|
104
|
+
* @return offset in days
|
|
105
|
+
*/
|
|
106
|
+
TuiYear.getYearStartDaysOffset = function (year, absoluteLeapYears) {
|
|
107
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
108
|
+
tuiAssert.assert(Number.isInteger(absoluteLeapYears));
|
|
109
|
+
tuiAssert.assert(year >= absoluteLeapYears);
|
|
110
|
+
tuiAssert.assert(absoluteLeapYears >= 0);
|
|
111
|
+
return ((absoluteLeapYears * DAYS_IN_LEAP_YEAR +
|
|
112
|
+
(year - absoluteLeapYears) * DAYS_IN_NORMAL_YEAR +
|
|
113
|
+
5) %
|
|
114
|
+
DAYS_IN_WEEK);
|
|
115
|
+
};
|
|
116
|
+
TuiYear.lengthBetween = function (from, to) {
|
|
117
|
+
return to.year - from.year;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Normalizes year by clamping it between min and max years
|
|
121
|
+
*/
|
|
122
|
+
TuiYear.normalizeYearPart = function (year) {
|
|
123
|
+
return normalizeToIntNumber(year, MIN_YEAR, MAX_YEAR);
|
|
124
|
+
};
|
|
73
125
|
Object.defineProperty(TuiYear.prototype, "formattedYear", {
|
|
74
126
|
get: function () {
|
|
75
127
|
return padStart(this.year.toString(), 4, '0');
|
|
@@ -162,54 +214,6 @@ var TuiYear = /** @class */ (function () {
|
|
|
162
214
|
TuiYear.prototype.toJSON = function () {
|
|
163
215
|
return this.formattedYear;
|
|
164
216
|
};
|
|
165
|
-
/**
|
|
166
|
-
* Checks year for validity
|
|
167
|
-
*/
|
|
168
|
-
TuiYear.isValidYear = function (year) {
|
|
169
|
-
return Number.isInteger(year) && inRange(year, MIN_YEAR, MAX_YEAR + 1);
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Check if passed year is a leap year
|
|
173
|
-
*/
|
|
174
|
-
TuiYear.isLeapYear = function (year) {
|
|
175
|
-
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
176
|
-
return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Returns amount of leap years from year 0 to the passed one
|
|
180
|
-
*/
|
|
181
|
-
TuiYear.getAbsoluteLeapYears = function (year) {
|
|
182
|
-
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
183
|
-
return Math.ceil(year / 400) + (Math.ceil(year / 4) - Math.ceil(year / 100));
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* @deprecated DONT USE IT (will be deleted soon)
|
|
187
|
-
*
|
|
188
|
-
* Returns day of week offset of the beginning of the passed year
|
|
189
|
-
*
|
|
190
|
-
* @param year
|
|
191
|
-
* @param absoluteLeapYears amount of leap years prior to the passed one
|
|
192
|
-
* @return offset in days
|
|
193
|
-
*/
|
|
194
|
-
TuiYear.getYearStartDaysOffset = function (year, absoluteLeapYears) {
|
|
195
|
-
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
196
|
-
tuiAssert.assert(Number.isInteger(absoluteLeapYears));
|
|
197
|
-
tuiAssert.assert(year >= absoluteLeapYears);
|
|
198
|
-
tuiAssert.assert(absoluteLeapYears >= 0);
|
|
199
|
-
return ((absoluteLeapYears * DAYS_IN_LEAP_YEAR +
|
|
200
|
-
(year - absoluteLeapYears) * DAYS_IN_NORMAL_YEAR +
|
|
201
|
-
5) %
|
|
202
|
-
DAYS_IN_WEEK);
|
|
203
|
-
};
|
|
204
|
-
TuiYear.lengthBetween = function (from, to) {
|
|
205
|
-
return to.year - from.year;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* Normalizes year by clamping it between min and max years
|
|
209
|
-
*/
|
|
210
|
-
TuiYear.normalizeYearPart = function (year) {
|
|
211
|
-
return normalizeToIntNumber(year, MIN_YEAR, MAX_YEAR);
|
|
212
|
-
};
|
|
213
217
|
return TuiYear;
|
|
214
218
|
}());
|
|
215
219
|
|
|
@@ -228,6 +232,61 @@ var TuiMonth = /** @class */ (function (_super) {
|
|
|
228
232
|
tuiAssert.assert(TuiMonth.isValidMonth(year, month));
|
|
229
233
|
return _this;
|
|
230
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Tests month and year for validity
|
|
237
|
+
*/
|
|
238
|
+
TuiMonth.isValidMonth = function (year, month) {
|
|
239
|
+
return TuiYear.isValidYear(year) && TuiMonth.isValidMonthPart(month);
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Returns number of days in a month
|
|
243
|
+
*/
|
|
244
|
+
TuiMonth.getMonthDaysCount = function (month, isLeapYear) {
|
|
245
|
+
tuiAssert.assert(TuiMonth.isValidMonthPart(month));
|
|
246
|
+
switch (month) {
|
|
247
|
+
case 1 /* February */:
|
|
248
|
+
return isLeapYear ? 29 : 28;
|
|
249
|
+
case 3 /* April */:
|
|
250
|
+
case 5 /* June */:
|
|
251
|
+
case 8 /* September */:
|
|
252
|
+
case 10 /* November */:
|
|
253
|
+
return 30;
|
|
254
|
+
default:
|
|
255
|
+
return 31;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Returns current month and year based on local time zone
|
|
260
|
+
* @nosideeffects
|
|
261
|
+
*/
|
|
262
|
+
TuiMonth.currentLocal = function () {
|
|
263
|
+
var nativeDate = new Date();
|
|
264
|
+
return new TuiMonth(nativeDate.getFullYear(), nativeDate.getMonth());
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Returns current month and year based on UTC
|
|
268
|
+
*/
|
|
269
|
+
TuiMonth.currentUtc = function () {
|
|
270
|
+
var nativeDate = new Date();
|
|
271
|
+
return new TuiMonth(nativeDate.getUTCFullYear(), nativeDate.getUTCMonth());
|
|
272
|
+
};
|
|
273
|
+
TuiMonth.lengthBetween = function (from, to) {
|
|
274
|
+
var absoluteFrom = from.month + from.year * 12;
|
|
275
|
+
var absoluteTo = to.month + to.year * 12;
|
|
276
|
+
return absoluteTo - absoluteFrom;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Normalizes number by clamping it between min and max month
|
|
280
|
+
*/
|
|
281
|
+
TuiMonth.normalizeMonthPart = function (month) {
|
|
282
|
+
return normalizeToIntNumber(month, MIN_MONTH, MAX_MONTH);
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Tests month for validity
|
|
286
|
+
*/
|
|
287
|
+
TuiMonth.isValidMonthPart = function (month) {
|
|
288
|
+
return Number.isInteger(month) && inRange(month, MIN_MONTH, MAX_MONTH + 1);
|
|
289
|
+
};
|
|
231
290
|
Object.defineProperty(TuiMonth.prototype, "formattedMonthPart", {
|
|
232
291
|
get: function () {
|
|
233
292
|
return padStart((this.month + 1).toString(), 2, '0');
|
|
@@ -353,76 +412,163 @@ var TuiMonth = /** @class */ (function (_super) {
|
|
|
353
412
|
TuiMonth.prototype.toUtcNativeDate = function () {
|
|
354
413
|
return new Date(Date.UTC(this.year, this.month));
|
|
355
414
|
};
|
|
415
|
+
return TuiMonth;
|
|
416
|
+
}(TuiYear));
|
|
417
|
+
|
|
418
|
+
// TODO: Localized formatting
|
|
419
|
+
/**
|
|
420
|
+
* Immutable date object, consisting of day, month and year
|
|
421
|
+
*/
|
|
422
|
+
var TuiDay = /** @class */ (function (_super) {
|
|
423
|
+
__extends(TuiDay, _super);
|
|
424
|
+
function TuiDay(year, month, day) {
|
|
425
|
+
var _this = _super.call(this, year, month) || this;
|
|
426
|
+
_this.day = day;
|
|
427
|
+
tuiAssert.assert(TuiDay.isValidDay(year, month, day));
|
|
428
|
+
return _this;
|
|
429
|
+
}
|
|
356
430
|
/**
|
|
357
|
-
*
|
|
431
|
+
* Creates {@link TuiDay} from native {@link Date} based on local time zone
|
|
358
432
|
*/
|
|
359
|
-
|
|
360
|
-
return
|
|
433
|
+
TuiDay.fromLocalNativeDate = function (date) {
|
|
434
|
+
return new TuiDay(date.getFullYear(), date.getMonth(), date.getDate());
|
|
361
435
|
};
|
|
362
436
|
/**
|
|
363
|
-
*
|
|
437
|
+
* Creates {@link TuiDay} from native {@link Date} using UTC
|
|
364
438
|
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
439
|
+
TuiDay.fromUtcNativeDate = function (date) {
|
|
440
|
+
return new TuiDay(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
441
|
+
};
|
|
442
|
+
/**
|
|
443
|
+
* Check validity of year, month and day
|
|
444
|
+
*
|
|
445
|
+
* @param year
|
|
446
|
+
* @param month
|
|
447
|
+
* @param day
|
|
448
|
+
* @return boolean validity
|
|
449
|
+
*/
|
|
450
|
+
TuiDay.isValidDay = function (year, month, day) {
|
|
451
|
+
return (TuiMonth.isValidMonth(year, month) &&
|
|
452
|
+
Number.isInteger(day) &&
|
|
453
|
+
inRange(day, MIN_DAY, TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year)) + 1));
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* @deprecated DONT USE IT (will be deleted soon)
|
|
457
|
+
*
|
|
458
|
+
* Calculated day on a calendar grid
|
|
459
|
+
*
|
|
460
|
+
* @param month
|
|
461
|
+
* @param row row in a calendar
|
|
462
|
+
* @param col column in a calendar
|
|
463
|
+
* @return resulting day on these coordinates (could exceed passed month)
|
|
464
|
+
*/
|
|
465
|
+
TuiDay.getDayFromMonthRowCol = function (month, row, col) {
|
|
466
|
+
tuiAssert.assert(Number.isInteger(row));
|
|
467
|
+
tuiAssert.assert(inRange(row, 0, 6));
|
|
468
|
+
tuiAssert.assert(Number.isInteger(col));
|
|
469
|
+
tuiAssert.assert(inRange(col, 0, DAYS_IN_WEEK));
|
|
470
|
+
var day = row * DAYS_IN_WEEK + col - month.monthStartDaysOffset + 1;
|
|
471
|
+
if (day > month.daysCount) {
|
|
472
|
+
day = day - month.daysCount;
|
|
473
|
+
month = month.append({ month: 1 });
|
|
377
474
|
}
|
|
475
|
+
if (day <= 0) {
|
|
476
|
+
month = month.append({ month: -1 });
|
|
477
|
+
day = month.daysCount + day;
|
|
478
|
+
}
|
|
479
|
+
return new TuiDay(month.year, month.month, day);
|
|
378
480
|
};
|
|
379
481
|
/**
|
|
380
|
-
*
|
|
381
|
-
* @nosideeffects
|
|
482
|
+
* Current day based on local time zone
|
|
382
483
|
*/
|
|
383
|
-
|
|
484
|
+
TuiDay.currentLocal = function () {
|
|
384
485
|
var nativeDate = new Date();
|
|
385
|
-
|
|
486
|
+
var year = nativeDate.getFullYear();
|
|
487
|
+
var month = nativeDate.getMonth();
|
|
488
|
+
var day = nativeDate.getDate();
|
|
489
|
+
return new TuiDay(year, month, day);
|
|
386
490
|
};
|
|
387
491
|
/**
|
|
388
|
-
*
|
|
492
|
+
* Calculates {@link TuiDay} normalizing year, month and day. {@link NaN} is turned into minimal value.
|
|
493
|
+
*
|
|
494
|
+
* @param year any year value, including invalid
|
|
495
|
+
* @param month any month value, including invalid (months start with 0)
|
|
496
|
+
* @param day any day value, including invalid
|
|
497
|
+
* @return normalized date
|
|
389
498
|
*/
|
|
390
|
-
|
|
391
|
-
var
|
|
392
|
-
|
|
499
|
+
TuiDay.normalizeOf = function (year, month, day) {
|
|
500
|
+
var normalizedYear = TuiYear.normalizeYearPart(year);
|
|
501
|
+
var normalizedMonth = TuiMonth.normalizeMonthPart(month);
|
|
502
|
+
var normalizedDay = TuiDay.normalizeDayPart(day, normalizedMonth, normalizedYear);
|
|
503
|
+
return new TuiDay(normalizedYear, normalizedMonth, normalizedDay);
|
|
393
504
|
};
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return absoluteTo - absoluteFrom;
|
|
505
|
+
TuiDay.lengthBetween = function (from, to) {
|
|
506
|
+
return Math.round((to.toLocalNativeDate().getTime() - from.toLocalNativeDate().getTime()) /
|
|
507
|
+
(1000 * 60 * 60 * 24));
|
|
398
508
|
};
|
|
509
|
+
TuiDay.parseRawDateString = function (date, dateMode) {
|
|
510
|
+
if (dateMode === void 0) { dateMode = 'DMY'; }
|
|
511
|
+
tuiAssert.assert(date.length === DATE_FILLER_LENGTH, '[parseRawDateString]: wrong date string length');
|
|
512
|
+
switch (dateMode) {
|
|
513
|
+
case 'YMD':
|
|
514
|
+
return {
|
|
515
|
+
day: parseInt(date.slice(8, 10), 10),
|
|
516
|
+
month: parseInt(date.slice(5, 7), 10) - 1,
|
|
517
|
+
year: parseInt(date.slice(0, 4), 10),
|
|
518
|
+
};
|
|
519
|
+
case 'MDY':
|
|
520
|
+
return {
|
|
521
|
+
day: parseInt(date.slice(3, 5), 10),
|
|
522
|
+
month: parseInt(date.slice(0, 2), 10) - 1,
|
|
523
|
+
year: parseInt(date.slice(6, 10), 10),
|
|
524
|
+
};
|
|
525
|
+
default:
|
|
526
|
+
case 'DMY':
|
|
527
|
+
return {
|
|
528
|
+
day: parseInt(date.slice(0, 2), 10),
|
|
529
|
+
month: parseInt(date.slice(3, 5), 10) - 1,
|
|
530
|
+
year: parseInt(date.slice(6, 10), 10),
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
// TODO: Move month and year related code corresponding classes
|
|
399
535
|
/**
|
|
400
|
-
*
|
|
536
|
+
* Parsing a string with date with normalization
|
|
537
|
+
*
|
|
538
|
+
* @param rawDate date string
|
|
539
|
+
* @param dateMode date format of the date string (DMY | MDY | YMD)
|
|
540
|
+
* @return normalized date
|
|
401
541
|
*/
|
|
402
|
-
|
|
403
|
-
|
|
542
|
+
TuiDay.normalizeParse = function (rawDate, dateMode) {
|
|
543
|
+
if (dateMode === void 0) { dateMode = 'DMY'; }
|
|
544
|
+
var _a = this.parseRawDateString(rawDate, dateMode), day = _a.day, month = _a.month, year = _a.year;
|
|
545
|
+
return TuiDay.normalizeOf(year, month, day);
|
|
404
546
|
};
|
|
405
547
|
/**
|
|
406
|
-
*
|
|
548
|
+
* Parsing a date stringified in a toJSON format
|
|
549
|
+
* @param yearMonthDayString date string in format of YYYY-MM-DD
|
|
550
|
+
* @return date
|
|
551
|
+
* @throws exceptions if any part of the date is invalid
|
|
407
552
|
*/
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
tuiAssert.assert(
|
|
424
|
-
|
|
425
|
-
|
|
553
|
+
TuiDay.jsonParse = function (yearMonthDayString) {
|
|
554
|
+
var _a = this.parseRawDateString(yearMonthDayString, 'YMD'), day = _a.day, month = _a.month, year = _a.year;
|
|
555
|
+
if (!TuiYear.isValidYear(year)) {
|
|
556
|
+
throw new Error('Invalid year: ' + year);
|
|
557
|
+
}
|
|
558
|
+
if (!TuiMonth.isValidMonth(year, month)) {
|
|
559
|
+
throw new Error('Invalid month: ' + month);
|
|
560
|
+
}
|
|
561
|
+
if (!Number.isInteger(day) ||
|
|
562
|
+
!inRange(day, MIN_DAY, TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year)) + 1)) {
|
|
563
|
+
throw new Error('Invalid day: ' + day);
|
|
564
|
+
}
|
|
565
|
+
return new TuiDay(year, month, day);
|
|
566
|
+
};
|
|
567
|
+
TuiDay.normalizeDayPart = function (day, month, year) {
|
|
568
|
+
tuiAssert.assert(TuiMonth.isValidMonth(year, month));
|
|
569
|
+
var monthDaysCount = TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year));
|
|
570
|
+
return normalizeToIntNumber(day, 1, monthDaysCount);
|
|
571
|
+
};
|
|
426
572
|
Object.defineProperty(TuiDay.prototype, "formattedDayPart", {
|
|
427
573
|
get: function () {
|
|
428
574
|
return padStart(this.day.toString(), 2, '0');
|
|
@@ -432,6 +578,8 @@ var TuiDay = /** @class */ (function (_super) {
|
|
|
432
578
|
});
|
|
433
579
|
Object.defineProperty(TuiDay.prototype, "formattedDay", {
|
|
434
580
|
/**
|
|
581
|
+
* @deprecated use {@link getFormattedDay} instead
|
|
582
|
+
* TODO remove in 3.0
|
|
435
583
|
* Formatted whole date
|
|
436
584
|
*/
|
|
437
585
|
get: function () {
|
|
@@ -557,8 +705,28 @@ var TuiDay = /** @class */ (function (_super) {
|
|
|
557
705
|
}
|
|
558
706
|
return new TuiDay(years, months, days);
|
|
559
707
|
};
|
|
560
|
-
|
|
561
|
-
|
|
708
|
+
/**
|
|
709
|
+
* Returns formatted whole date
|
|
710
|
+
*/
|
|
711
|
+
TuiDay.prototype.getFormattedDay = function (dateFormat, separator) {
|
|
712
|
+
tuiAssert.assert(separator.length === 1, 'Separator should consist of only 1 symbol');
|
|
713
|
+
var dd = this.formattedDayPart;
|
|
714
|
+
var mm = this.formattedMonthPart;
|
|
715
|
+
var yyyy = this.formattedYear;
|
|
716
|
+
switch (dateFormat) {
|
|
717
|
+
case 'YMD':
|
|
718
|
+
return "" + yyyy + separator + mm + separator + dd;
|
|
719
|
+
case 'MDY':
|
|
720
|
+
return "" + mm + separator + dd + separator + yyyy;
|
|
721
|
+
case 'DMY':
|
|
722
|
+
default:
|
|
723
|
+
return "" + dd + separator + mm + separator + yyyy;
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
TuiDay.prototype.toString = function (dateFormat, separator) {
|
|
727
|
+
if (dateFormat === void 0) { dateFormat = 'DMY'; }
|
|
728
|
+
if (separator === void 0) { separator = '.'; }
|
|
729
|
+
return this.getFormattedDay(dateFormat, separator);
|
|
562
730
|
};
|
|
563
731
|
TuiDay.prototype.toJSON = function () {
|
|
564
732
|
return _super.prototype.toJSON.call(this) + "-" + this.formattedDayPart;
|
|
@@ -575,125 +743,6 @@ var TuiDay = /** @class */ (function (_super) {
|
|
|
575
743
|
TuiDay.prototype.toUtcNativeDate = function () {
|
|
576
744
|
return new Date(Date.UTC(this.year, this.month, this.day));
|
|
577
745
|
};
|
|
578
|
-
/**
|
|
579
|
-
* Creates {@link TuiDay} from native {@link Date} based on local time zone
|
|
580
|
-
*/
|
|
581
|
-
TuiDay.fromLocalNativeDate = function (date) {
|
|
582
|
-
return new TuiDay(date.getFullYear(), date.getMonth(), date.getDate());
|
|
583
|
-
};
|
|
584
|
-
/**
|
|
585
|
-
* Creates {@link TuiDay} from native {@link Date} using UTC
|
|
586
|
-
*/
|
|
587
|
-
TuiDay.fromUtcNativeDate = function (date) {
|
|
588
|
-
return new TuiDay(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
589
|
-
};
|
|
590
|
-
/**
|
|
591
|
-
* Check validity of year, month and day
|
|
592
|
-
*
|
|
593
|
-
* @param year
|
|
594
|
-
* @param month
|
|
595
|
-
* @param day
|
|
596
|
-
* @return boolean validity
|
|
597
|
-
*/
|
|
598
|
-
TuiDay.isValidDay = function (year, month, day) {
|
|
599
|
-
return (TuiMonth.isValidMonth(year, month) &&
|
|
600
|
-
Number.isInteger(day) &&
|
|
601
|
-
inRange(day, MIN_DAY, TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year)) + 1));
|
|
602
|
-
};
|
|
603
|
-
/**
|
|
604
|
-
* @deprecated DONT USE IT (will be deleted soon)
|
|
605
|
-
*
|
|
606
|
-
* Calculated day on a calendar grid
|
|
607
|
-
*
|
|
608
|
-
* @param month
|
|
609
|
-
* @param row row in a calendar
|
|
610
|
-
* @param col column in a calendar
|
|
611
|
-
* @return resulting day on these coordinates (could exceed passed month)
|
|
612
|
-
*/
|
|
613
|
-
TuiDay.getDayFromMonthRowCol = function (month, row, col) {
|
|
614
|
-
tuiAssert.assert(Number.isInteger(row));
|
|
615
|
-
tuiAssert.assert(inRange(row, 0, 6));
|
|
616
|
-
tuiAssert.assert(Number.isInteger(col));
|
|
617
|
-
tuiAssert.assert(inRange(col, 0, DAYS_IN_WEEK));
|
|
618
|
-
var day = row * DAYS_IN_WEEK + col - month.monthStartDaysOffset + 1;
|
|
619
|
-
if (day > month.daysCount) {
|
|
620
|
-
day = day - month.daysCount;
|
|
621
|
-
month = month.append({ month: 1 });
|
|
622
|
-
}
|
|
623
|
-
if (day <= 0) {
|
|
624
|
-
month = month.append({ month: -1 });
|
|
625
|
-
day = month.daysCount + day;
|
|
626
|
-
}
|
|
627
|
-
return new TuiDay(month.year, month.month, day);
|
|
628
|
-
};
|
|
629
|
-
/**
|
|
630
|
-
* Current day based on local time zone
|
|
631
|
-
*/
|
|
632
|
-
TuiDay.currentLocal = function () {
|
|
633
|
-
var nativeDate = new Date();
|
|
634
|
-
var year = nativeDate.getFullYear();
|
|
635
|
-
var month = nativeDate.getMonth();
|
|
636
|
-
var day = nativeDate.getDate();
|
|
637
|
-
return new TuiDay(year, month, day);
|
|
638
|
-
};
|
|
639
|
-
/**
|
|
640
|
-
* Calculates {@link TuiDay} normalizing year, month and day. {@link NaN} is turned into minimal value.
|
|
641
|
-
*
|
|
642
|
-
* @param year any year value, including invalid
|
|
643
|
-
* @param month any month value, including invalid (months start with 0)
|
|
644
|
-
* @param day any day value, including invalid
|
|
645
|
-
* @return normalized date
|
|
646
|
-
*/
|
|
647
|
-
TuiDay.normalizeOf = function (year, month, day) {
|
|
648
|
-
var normalizedYear = TuiYear.normalizeYearPart(year);
|
|
649
|
-
var normalizedMonth = TuiMonth.normalizeMonthPart(month);
|
|
650
|
-
var normalizedDay = TuiDay.normalizeDayPart(day, normalizedMonth, normalizedYear);
|
|
651
|
-
return new TuiDay(normalizedYear, normalizedMonth, normalizedDay);
|
|
652
|
-
};
|
|
653
|
-
TuiDay.lengthBetween = function (from, to) {
|
|
654
|
-
return Math.round((to.toLocalNativeDate().getTime() - from.toLocalNativeDate().getTime()) /
|
|
655
|
-
(1000 * 60 * 60 * 24));
|
|
656
|
-
};
|
|
657
|
-
// TODO: Move month and year related code corresponding classes
|
|
658
|
-
/**
|
|
659
|
-
* Parsing a string with date with normalization
|
|
660
|
-
*
|
|
661
|
-
* @param yearMonthDayString date string in format of DD.MM.Yyyy
|
|
662
|
-
* @return normalized date
|
|
663
|
-
*/
|
|
664
|
-
TuiDay.normalizeParse = function (yearMonthDayString) {
|
|
665
|
-
var day = parseInt(yearMonthDayString.slice(0, 2), 10);
|
|
666
|
-
var month = parseInt(yearMonthDayString.slice(3, 5), 10) - 1;
|
|
667
|
-
var year = parseInt(yearMonthDayString.slice(6, 10), 10);
|
|
668
|
-
return TuiDay.normalizeOf(year, month, day);
|
|
669
|
-
};
|
|
670
|
-
/**
|
|
671
|
-
* Parsing a date stringified in a toJSON format
|
|
672
|
-
* @param yearMonthDayString date string in format of YYYY-MM-DD
|
|
673
|
-
* @return date
|
|
674
|
-
* @throws exceptions if any part of the date is invalid
|
|
675
|
-
*/
|
|
676
|
-
TuiDay.jsonParse = function (yearMonthDayString) {
|
|
677
|
-
var day = parseInt(yearMonthDayString.slice(8, 10), 10);
|
|
678
|
-
var month = parseInt(yearMonthDayString.slice(5, 7), 10) - 1;
|
|
679
|
-
var year = parseInt(yearMonthDayString.slice(0, 4), 10);
|
|
680
|
-
if (!TuiYear.isValidYear(year)) {
|
|
681
|
-
throw new Error('Invalid year: ' + year);
|
|
682
|
-
}
|
|
683
|
-
if (!TuiMonth.isValidMonth(year, month)) {
|
|
684
|
-
throw new Error('Invalid month: ' + month);
|
|
685
|
-
}
|
|
686
|
-
if (!Number.isInteger(day) ||
|
|
687
|
-
!inRange(day, MIN_DAY, TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year)) + 1)) {
|
|
688
|
-
throw new Error('Invalid day: ' + day);
|
|
689
|
-
}
|
|
690
|
-
return new TuiDay(year, month, day);
|
|
691
|
-
};
|
|
692
|
-
TuiDay.normalizeDayPart = function (day, month, year) {
|
|
693
|
-
tuiAssert.assert(TuiMonth.isValidMonth(year, month));
|
|
694
|
-
var monthDaysCount = TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year));
|
|
695
|
-
return normalizeToIntNumber(day, 1, monthDaysCount);
|
|
696
|
-
};
|
|
697
746
|
return TuiDay;
|
|
698
747
|
}(TuiMonth));
|
|
699
748
|
|
|
@@ -706,6 +755,11 @@ var TuiMonthRange = /** @class */ (function () {
|
|
|
706
755
|
this.to = to;
|
|
707
756
|
tuiAssert.assert(from.monthSameOrBefore(to));
|
|
708
757
|
}
|
|
758
|
+
TuiMonthRange.sort = function (month1, month2) {
|
|
759
|
+
return month1.monthSameOrBefore(month2)
|
|
760
|
+
? new TuiMonthRange(month1, month2)
|
|
761
|
+
: new TuiMonthRange(month2, month1);
|
|
762
|
+
};
|
|
709
763
|
Object.defineProperty(TuiMonthRange.prototype, "isSingleMonth", {
|
|
710
764
|
get: function () {
|
|
711
765
|
return this.from.monthSame(this.to);
|
|
@@ -726,14 +780,16 @@ var TuiMonthRange = /** @class */ (function () {
|
|
|
726
780
|
TuiMonthRange.prototype.toString = function () {
|
|
727
781
|
return "" + this.from + RANGE_SEPARATOR_CHAR + this.to;
|
|
728
782
|
};
|
|
729
|
-
TuiMonthRange.sort = function (month1, month2) {
|
|
730
|
-
return month1.monthSameOrBefore(month2)
|
|
731
|
-
? new TuiMonthRange(month1, month2)
|
|
732
|
-
: new TuiMonthRange(month2, month1);
|
|
733
|
-
};
|
|
734
783
|
return TuiMonthRange;
|
|
735
784
|
}());
|
|
736
785
|
|
|
786
|
+
/**
|
|
787
|
+
* Temporary type guard to satisfy ts-overloading of normalizeParse method
|
|
788
|
+
* @deprecated TODO rm in v3.0
|
|
789
|
+
*/
|
|
790
|
+
var isDateMode = function (dateMode) {
|
|
791
|
+
return ['DMY', 'YMD', 'MDY'].includes(dateMode);
|
|
792
|
+
};
|
|
737
793
|
/**
|
|
738
794
|
* An immutable range of two {@link TuiDay} objects
|
|
739
795
|
*/
|
|
@@ -746,6 +802,34 @@ var TuiDayRange = /** @class */ (function (_super) {
|
|
|
746
802
|
tuiAssert.assert(from.daySameOrBefore(to));
|
|
747
803
|
return _this;
|
|
748
804
|
}
|
|
805
|
+
/**
|
|
806
|
+
* Creates range from two days after sorting them
|
|
807
|
+
*
|
|
808
|
+
* @param day1
|
|
809
|
+
* @param day2
|
|
810
|
+
* @return new range with sorted days
|
|
811
|
+
*/
|
|
812
|
+
TuiDayRange.sort = function (day1, day2) {
|
|
813
|
+
return day1.daySameOrBefore(day2)
|
|
814
|
+
? new TuiDayRange(day1, day2)
|
|
815
|
+
: new TuiDayRange(day2, day1);
|
|
816
|
+
};
|
|
817
|
+
/**
|
|
818
|
+
* Parse and correct a day range in string format
|
|
819
|
+
*
|
|
820
|
+
* @param rangeString a string of dates in a format dd.mm.yyyy - dd.mm.yyyy
|
|
821
|
+
* @param dateMode {@link TuiDateMode}
|
|
822
|
+
* @return normalized day range object
|
|
823
|
+
*/
|
|
824
|
+
TuiDayRange.normalizeParse = function (rangeString, dateMode) {
|
|
825
|
+
if (dateMode === void 0) { dateMode = 'DMY'; }
|
|
826
|
+
var dateFormat = isDateMode(dateMode) ? dateMode : 'DMY';
|
|
827
|
+
var leftDay = TuiDay.normalizeParse(rangeString.slice(0, DATE_FILLER_LENGTH), dateFormat);
|
|
828
|
+
if (rangeString.length < DATE_RANGE_FILLER_LENGTH) {
|
|
829
|
+
return new TuiDayRange(leftDay, leftDay);
|
|
830
|
+
}
|
|
831
|
+
return TuiDayRange.sort(leftDay, TuiDay.normalizeParse(rangeString.slice(DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length), dateFormat));
|
|
832
|
+
};
|
|
749
833
|
Object.defineProperty(TuiDayRange.prototype, "isSingleDay", {
|
|
750
834
|
get: function () {
|
|
751
835
|
return this.from.daySame(this.to);
|
|
@@ -756,9 +840,12 @@ var TuiDayRange = /** @class */ (function (_super) {
|
|
|
756
840
|
Object.defineProperty(TuiDayRange.prototype, "formattedDayRange", {
|
|
757
841
|
/**
|
|
758
842
|
* Human readable format.
|
|
843
|
+
* @deprecated use {@link getFormattedDayRange} instead
|
|
759
844
|
*/
|
|
760
845
|
get: function () {
|
|
761
|
-
|
|
846
|
+
var from = this.from.getFormattedDay('DMY', '.');
|
|
847
|
+
var to = this.to.getFormattedDay('DMY', '.');
|
|
848
|
+
return "" + from + RANGE_SEPARATOR_CHAR + to;
|
|
762
849
|
},
|
|
763
850
|
enumerable: true,
|
|
764
851
|
configurable: true
|
|
@@ -783,29 +870,19 @@ var TuiDayRange = /** @class */ (function (_super) {
|
|
|
783
870
|
return new TuiDayRange(this.from.dayLimit(min, max), this.to.dayLimit(min, max));
|
|
784
871
|
};
|
|
785
872
|
/**
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
* @param day1
|
|
789
|
-
* @param day2
|
|
790
|
-
* @return new range with sorted days
|
|
873
|
+
* Human readable format.
|
|
791
874
|
*/
|
|
792
|
-
TuiDayRange.
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
875
|
+
TuiDayRange.prototype.getFormattedDayRange = function (dateFormat, dateSeparator) {
|
|
876
|
+
var from = this.from.getFormattedDay(dateFormat, dateSeparator);
|
|
877
|
+
var to = this.to.getFormattedDay(dateFormat, dateSeparator);
|
|
878
|
+
return "" + from + RANGE_SEPARATOR_CHAR + to;
|
|
796
879
|
};
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
TuiDayRange.normalizeParse = function (rangeString) {
|
|
804
|
-
var leftDay = TuiDay.normalizeParse(rangeString.slice(0, DATE_FILLER_LENGTH));
|
|
805
|
-
if (rangeString.length < DATE_RANGE_FILLER_LENGTH) {
|
|
806
|
-
return new TuiDayRange(leftDay, leftDay);
|
|
807
|
-
}
|
|
808
|
-
return TuiDayRange.sort(leftDay, TuiDay.normalizeParse(rangeString.slice(DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length)));
|
|
880
|
+
TuiDayRange.prototype.toString = function (dateFormat, dateSeparator) {
|
|
881
|
+
if (dateFormat === void 0) { dateFormat = 'DMY'; }
|
|
882
|
+
if (dateSeparator === void 0) { dateSeparator = '.'; }
|
|
883
|
+
var from = this.from.getFormattedDay(dateFormat, dateSeparator);
|
|
884
|
+
var to = this.to.getFormattedDay(dateFormat, dateSeparator);
|
|
885
|
+
return "" + from + RANGE_SEPARATOR_CHAR + to;
|
|
809
886
|
};
|
|
810
887
|
return TuiDayRange;
|
|
811
888
|
}(TuiMonthRange));
|
|
@@ -826,46 +903,6 @@ var TuiTime = /** @class */ (function () {
|
|
|
826
903
|
this.ms = ms;
|
|
827
904
|
tuiAssert.assert(TuiTime.isValidTime(hours, minutes, seconds, ms), 'Time must be real, but got:', hours, minutes, seconds, ms);
|
|
828
905
|
}
|
|
829
|
-
/**
|
|
830
|
-
* Shifts time by hours and minutes
|
|
831
|
-
*/
|
|
832
|
-
TuiTime.prototype.shift = function (_a) {
|
|
833
|
-
var _b = _a.hours, hours = _b === void 0 ? 0 : _b, _c = _a.minutes, minutes = _c === void 0 ? 0 : _c, _d = _a.seconds, seconds = _d === void 0 ? 0 : _d, _e = _a.ms, ms = _e === void 0 ? 0 : _e;
|
|
834
|
-
var newMs = (1000 + this.ms + (ms % 1000)) % 1000;
|
|
835
|
-
var secondsInMs = ms < 0 ? Math.ceil(ms / 1000) : Math.floor(ms / 1000);
|
|
836
|
-
var secondsToAdd = secondsInMs + seconds;
|
|
837
|
-
var newSeconds = (60 + this.seconds + (secondsToAdd % 60)) % 60;
|
|
838
|
-
var minutesInSeconds = secondsToAdd < 0
|
|
839
|
-
? Math.ceil(secondsToAdd / 60)
|
|
840
|
-
: Math.floor(secondsToAdd / 60);
|
|
841
|
-
var minutesToAdd = minutesInSeconds + minutes;
|
|
842
|
-
var newMinutes = (60 + this.minutes + (minutesToAdd % 60)) % 60;
|
|
843
|
-
var hoursInMinutes = minutesToAdd < 0
|
|
844
|
-
? Math.ceil(minutesToAdd / 60)
|
|
845
|
-
: Math.floor(minutesToAdd / 60);
|
|
846
|
-
var hoursToAdd = hoursInMinutes + hours;
|
|
847
|
-
var newHours = (24 + this.hours + (hoursToAdd % 24)) % 24;
|
|
848
|
-
return new TuiTime(newHours, newMinutes, newSeconds, newMs);
|
|
849
|
-
};
|
|
850
|
-
/**
|
|
851
|
-
* Converts TuiTime to string
|
|
852
|
-
*/
|
|
853
|
-
TuiTime.prototype.toString = function (mode) {
|
|
854
|
-
var needAddMs = mode === 'HH:MM:SS.MSS' || (!mode && this.ms > 0);
|
|
855
|
-
var needAddSeconds = needAddMs || mode === 'HH:MM:SS' || (!mode && this.seconds > 0);
|
|
856
|
-
return (this.formatTime(this.hours) + ":" + this.formatTime(this.minutes) +
|
|
857
|
-
("" + (needAddSeconds ? ':' + this.formatTime(this.seconds) : '')) +
|
|
858
|
-
("" + (needAddMs ? '.' + this.formatTime(this.ms, 3) : '')));
|
|
859
|
-
};
|
|
860
|
-
/**
|
|
861
|
-
* Converts TuiTime to milliseconds
|
|
862
|
-
*/
|
|
863
|
-
TuiTime.prototype.toAbsoluteMilliseconds = function () {
|
|
864
|
-
return (this.hours * MILLISECONDS_IN_HOUR +
|
|
865
|
-
this.minutes * MILLISECONDS_IN_MINUTE +
|
|
866
|
-
this.seconds * 1000 +
|
|
867
|
-
this.ms);
|
|
868
|
-
};
|
|
869
906
|
/**
|
|
870
907
|
* Checks if time is valid
|
|
871
908
|
*/
|
|
@@ -924,6 +961,46 @@ var TuiTime = /** @class */ (function () {
|
|
|
924
961
|
TuiTime.fromLocalNativeDate = function (date) {
|
|
925
962
|
return new TuiTime(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
926
963
|
};
|
|
964
|
+
/**
|
|
965
|
+
* Shifts time by hours and minutes
|
|
966
|
+
*/
|
|
967
|
+
TuiTime.prototype.shift = function (_a) {
|
|
968
|
+
var _b = _a.hours, hours = _b === void 0 ? 0 : _b, _c = _a.minutes, minutes = _c === void 0 ? 0 : _c, _d = _a.seconds, seconds = _d === void 0 ? 0 : _d, _e = _a.ms, ms = _e === void 0 ? 0 : _e;
|
|
969
|
+
var newMs = (1000 + this.ms + (ms % 1000)) % 1000;
|
|
970
|
+
var secondsInMs = ms < 0 ? Math.ceil(ms / 1000) : Math.floor(ms / 1000);
|
|
971
|
+
var secondsToAdd = secondsInMs + seconds;
|
|
972
|
+
var newSeconds = (60 + this.seconds + (secondsToAdd % 60)) % 60;
|
|
973
|
+
var minutesInSeconds = secondsToAdd < 0
|
|
974
|
+
? Math.ceil(secondsToAdd / 60)
|
|
975
|
+
: Math.floor(secondsToAdd / 60);
|
|
976
|
+
var minutesToAdd = minutesInSeconds + minutes;
|
|
977
|
+
var newMinutes = (60 + this.minutes + (minutesToAdd % 60)) % 60;
|
|
978
|
+
var hoursInMinutes = minutesToAdd < 0
|
|
979
|
+
? Math.ceil(minutesToAdd / 60)
|
|
980
|
+
: Math.floor(minutesToAdd / 60);
|
|
981
|
+
var hoursToAdd = hoursInMinutes + hours;
|
|
982
|
+
var newHours = (24 + this.hours + (hoursToAdd % 24)) % 24;
|
|
983
|
+
return new TuiTime(newHours, newMinutes, newSeconds, newMs);
|
|
984
|
+
};
|
|
985
|
+
/**
|
|
986
|
+
* Converts TuiTime to string
|
|
987
|
+
*/
|
|
988
|
+
TuiTime.prototype.toString = function (mode) {
|
|
989
|
+
var needAddMs = mode === 'HH:MM:SS.MSS' || (!mode && this.ms > 0);
|
|
990
|
+
var needAddSeconds = needAddMs || mode === 'HH:MM:SS' || (!mode && this.seconds > 0);
|
|
991
|
+
return (this.formatTime(this.hours) + ":" + this.formatTime(this.minutes) +
|
|
992
|
+
("" + (needAddSeconds ? ':' + this.formatTime(this.seconds) : '')) +
|
|
993
|
+
("" + (needAddMs ? '.' + this.formatTime(this.ms, 3) : '')));
|
|
994
|
+
};
|
|
995
|
+
/**
|
|
996
|
+
* Converts TuiTime to milliseconds
|
|
997
|
+
*/
|
|
998
|
+
TuiTime.prototype.toAbsoluteMilliseconds = function () {
|
|
999
|
+
return (this.hours * MILLISECONDS_IN_HOUR +
|
|
1000
|
+
this.minutes * MILLISECONDS_IN_MINUTE +
|
|
1001
|
+
this.seconds * 1000 +
|
|
1002
|
+
this.ms);
|
|
1003
|
+
};
|
|
927
1004
|
TuiTime.prototype.formatTime = function (time, digits) {
|
|
928
1005
|
if (digits === void 0) { digits = 2; }
|
|
929
1006
|
return padStart(time.toString(), digits, '0');
|
|
@@ -935,5 +1012,5 @@ var TuiTime = /** @class */ (function () {
|
|
|
935
1012
|
* Generated bundle index. Do not edit.
|
|
936
1013
|
*/
|
|
937
1014
|
|
|
938
|
-
export { DATE_FILLER_LENGTH, DATE_RANGE_FILLER_LENGTH, DAYS_IN_LEAP_YEAR, DAYS_IN_NORMAL_YEAR, DAYS_IN_WEEK, HOURS_IN_DAY, MAX_MONTH, MAX_YEAR, MILLISECONDS_IN_DAY, MILLISECONDS_IN_HOUR, MILLISECONDS_IN_MINUTE, MILLISECONDS_IN_SECOND, MINUTES_IN_HOUR, MIN_DAY, MIN_MONTH, MIN_YEAR, MONTHS_IN_YEAR, RANGE_SEPARATOR_CHAR, SECONDS_IN_MINUTE, TUI_DATE_FILLER, TUI_DATE_FORMAT, TUI_DATE_RANGE_FILLER, TUI_FIRST_DAY, TUI_LAST_DAY, TuiDay, TuiDayRange, TuiMonth, TuiMonthRange, TuiTime, TuiYear };
|
|
1015
|
+
export { DATE_FILLER_LENGTH, DATE_RANGE_FILLER_LENGTH, DAYS_IN_LEAP_YEAR, DAYS_IN_NORMAL_YEAR, DAYS_IN_WEEK, HOURS_IN_DAY, MAX_MONTH, MAX_YEAR, MILLISECONDS_IN_DAY, MILLISECONDS_IN_HOUR, MILLISECONDS_IN_MINUTE, MILLISECONDS_IN_SECOND, MINUTES_IN_HOUR, MIN_DAY, MIN_MONTH, MIN_YEAR, MONTHS_IN_YEAR, RANGE_SEPARATOR_CHAR, SECONDS_IN_MINUTE, TUI_DATE_FILLER, TUI_DATE_FORMAT, TUI_DATE_RANGE_FILLER, TUI_DATE_SEPARATOR, TUI_FIRST_DAY, TUI_LAST_DAY, TuiDay, TuiDayRange, TuiMonth, TuiMonthRange, TuiTime, TuiYear, isDateMode };
|
|
939
1016
|
//# sourceMappingURL=taiga-ui-cdk-date-time.js.map
|