@taiga-ui/cdk 2.25.0 → 2.28.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/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 +331 -331
- 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-item.umd.js +259 -0
- package/bundles/taiga-ui-cdk-directives-item.umd.js.map +1 -0
- package/bundles/taiga-ui-cdk-directives-item.umd.min.js +16 -0
- package/bundles/taiga-ui-cdk-directives-item.umd.min.js.map +1 -0
- 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-directives-pan.umd.js +5 -5
- package/bundles/taiga-ui-cdk-directives-pan.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-pan.umd.min.js +2 -2
- package/bundles/taiga-ui-cdk-directives-pan.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-swipe.umd.js +5 -5
- package/bundles/taiga-ui-cdk-directives-swipe.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-swipe.umd.min.js +2 -2
- package/bundles/taiga-ui-cdk-directives-swipe.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-zoom.umd.js +5 -5
- package/bundles/taiga-ui-cdk-directives-zoom.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-zoom.umd.min.js +2 -2
- package/bundles/taiga-ui-cdk-directives-zoom.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives.umd.js +12 -4
- package/bundles/taiga-ui-cdk-directives.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-services.umd.js +2 -2
- 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 +3 -0
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.min.js.map +1 -1
- package/date-time/day-range.d.ts +14 -14
- package/date-time/day.d.ts +57 -57
- 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/index.d.ts +1 -0
- package/directives/item/index.d.ts +2 -0
- package/directives/item/item.directive.d.ts +6 -0
- package/directives/item/item.module.d.ts +2 -0
- package/directives/item/package.json +13 -0
- package/directives/item/taiga-ui-cdk-directives-item.d.ts +4 -0
- package/directives/item/taiga-ui-cdk-directives-item.metadata.json +1 -0
- package/directives/media/media.directive.d.ts +1 -1
- package/directives/media/taiga-ui-cdk-directives-media.metadata.json +1 -1
- package/directives/pan/pan.directive.d.ts +3 -3
- package/directives/pan/taiga-ui-cdk-directives-pan.metadata.json +1 -1
- package/directives/swipe/swipe.directive.d.ts +4 -3
- package/directives/swipe/taiga-ui-cdk-directives-swipe.metadata.json +1 -1
- package/directives/taiga-ui-cdk-directives.metadata.json +1 -1
- package/directives/zoom/taiga-ui-cdk-directives-zoom.metadata.json +1 -1
- package/directives/zoom/zoom.directive.d.ts +4 -3
- package/esm2015/abstract/control.js +1 -1
- package/esm2015/abstract/interactive.js +4 -4
- package/esm2015/date-time/day-range.js +26 -26
- package/esm2015/date-time/day.js +120 -120
- 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/index.js +2 -1
- package/esm2015/directives/item/index.js +3 -0
- package/esm2015/directives/item/item.directive.js +15 -0
- package/esm2015/directives/item/item.module.js +13 -0
- package/esm2015/directives/item/taiga-ui-cdk-directives-item.js +5 -0
- package/esm2015/directives/media/media.directive.js +2 -2
- package/esm2015/directives/pan/pan.directive.js +3 -2
- package/esm2015/directives/swipe/swipe.directive.js +3 -2
- package/esm2015/directives/zoom/zoom.directive.js +3 -2
- package/esm2015/interfaces/focusable-element-accessor.js +1 -1
- package/esm2015/services/pan.service.js +3 -3
- package/esm2015/tokens/index.js +2 -1
- package/esm2015/tokens/touch-supported.js +6 -0
- 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/day-range.js +26 -26
- package/esm5/date-time/day.js +120 -120
- 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/index.js +2 -1
- package/esm5/directives/item/index.js +3 -0
- package/esm5/directives/item/item.directive.js +18 -0
- package/esm5/directives/item/item.module.js +16 -0
- package/esm5/directives/item/taiga-ui-cdk-directives-item.js +5 -0
- package/esm5/directives/media/media.directive.js +2 -2
- package/esm5/directives/pan/pan.directive.js +3 -2
- package/esm5/directives/swipe/swipe.directive.js +3 -2
- package/esm5/directives/zoom/zoom.directive.js +3 -2
- package/esm5/interfaces/focusable-element-accessor.js +1 -1
- package/esm5/services/pan.service.js +3 -3
- package/esm5/tokens/index.js +2 -1
- package/esm5/tokens/touch-supported.js +6 -0
- 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 +322 -322
- 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-item.js +30 -0
- package/fesm2015/taiga-ui-cdk-directives-item.js.map +1 -0
- 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-directives-pan.js +2 -1
- package/fesm2015/taiga-ui-cdk-directives-pan.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-swipe.js +2 -1
- package/fesm2015/taiga-ui-cdk-directives-swipe.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-zoom.js +2 -1
- package/fesm2015/taiga-ui-cdk-directives-zoom.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives.js +1 -0
- package/fesm2015/taiga-ui-cdk-directives.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-services.js +2 -2
- 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 +3 -0
- 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 +331 -331
- 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-item.js +36 -0
- package/fesm5/taiga-ui-cdk-directives-item.js.map +1 -0
- 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-directives-pan.js +2 -1
- package/fesm5/taiga-ui-cdk-directives-pan.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-swipe.js +2 -1
- package/fesm5/taiga-ui-cdk-directives-swipe.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-zoom.js +2 -1
- package/fesm5/taiga-ui-cdk-directives-zoom.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives.js +1 -0
- package/fesm5/taiga-ui-cdk-directives.js.map +1 -1
- package/fesm5/taiga-ui-cdk-services.js +2 -2
- 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 +3 -0
- package/fesm5/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
- package/interfaces/focusable-element-accessor.d.ts +2 -0
- package/package.json +2 -2
- 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
|
@@ -70,6 +70,54 @@ var TuiYear = /** @class */ (function () {
|
|
|
70
70
|
this.year = year;
|
|
71
71
|
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Checks year for validity
|
|
75
|
+
*/
|
|
76
|
+
TuiYear.isValidYear = function (year) {
|
|
77
|
+
return Number.isInteger(year) && inRange(year, MIN_YEAR, MAX_YEAR + 1);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Check if passed year is a leap year
|
|
81
|
+
*/
|
|
82
|
+
TuiYear.isLeapYear = function (year) {
|
|
83
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
84
|
+
return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Returns amount of leap years from year 0 to the passed one
|
|
88
|
+
*/
|
|
89
|
+
TuiYear.getAbsoluteLeapYears = function (year) {
|
|
90
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
91
|
+
return Math.ceil(year / 400) + (Math.ceil(year / 4) - Math.ceil(year / 100));
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated DONT USE IT (will be deleted soon)
|
|
95
|
+
*
|
|
96
|
+
* Returns day of week offset of the beginning of the passed year
|
|
97
|
+
*
|
|
98
|
+
* @param year
|
|
99
|
+
* @param absoluteLeapYears amount of leap years prior to the passed one
|
|
100
|
+
* @return offset in days
|
|
101
|
+
*/
|
|
102
|
+
TuiYear.getYearStartDaysOffset = function (year, absoluteLeapYears) {
|
|
103
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
104
|
+
tuiAssert.assert(Number.isInteger(absoluteLeapYears));
|
|
105
|
+
tuiAssert.assert(year >= absoluteLeapYears);
|
|
106
|
+
tuiAssert.assert(absoluteLeapYears >= 0);
|
|
107
|
+
return ((absoluteLeapYears * DAYS_IN_LEAP_YEAR +
|
|
108
|
+
(year - absoluteLeapYears) * DAYS_IN_NORMAL_YEAR +
|
|
109
|
+
5) %
|
|
110
|
+
DAYS_IN_WEEK);
|
|
111
|
+
};
|
|
112
|
+
TuiYear.lengthBetween = function (from, to) {
|
|
113
|
+
return to.year - from.year;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Normalizes year by clamping it between min and max years
|
|
117
|
+
*/
|
|
118
|
+
TuiYear.normalizeYearPart = function (year) {
|
|
119
|
+
return normalizeToIntNumber(year, MIN_YEAR, MAX_YEAR);
|
|
120
|
+
};
|
|
73
121
|
Object.defineProperty(TuiYear.prototype, "formattedYear", {
|
|
74
122
|
get: function () {
|
|
75
123
|
return padStart(this.year.toString(), 4, '0');
|
|
@@ -162,54 +210,6 @@ var TuiYear = /** @class */ (function () {
|
|
|
162
210
|
TuiYear.prototype.toJSON = function () {
|
|
163
211
|
return this.formattedYear;
|
|
164
212
|
};
|
|
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
213
|
return TuiYear;
|
|
214
214
|
}());
|
|
215
215
|
|
|
@@ -228,6 +228,61 @@ var TuiMonth = /** @class */ (function (_super) {
|
|
|
228
228
|
tuiAssert.assert(TuiMonth.isValidMonth(year, month));
|
|
229
229
|
return _this;
|
|
230
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Tests month and year for validity
|
|
233
|
+
*/
|
|
234
|
+
TuiMonth.isValidMonth = function (year, month) {
|
|
235
|
+
return TuiYear.isValidYear(year) && TuiMonth.isValidMonthPart(month);
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Returns number of days in a month
|
|
239
|
+
*/
|
|
240
|
+
TuiMonth.getMonthDaysCount = function (month, isLeapYear) {
|
|
241
|
+
tuiAssert.assert(TuiMonth.isValidMonthPart(month));
|
|
242
|
+
switch (month) {
|
|
243
|
+
case 1 /* February */:
|
|
244
|
+
return isLeapYear ? 29 : 28;
|
|
245
|
+
case 3 /* April */:
|
|
246
|
+
case 5 /* June */:
|
|
247
|
+
case 8 /* September */:
|
|
248
|
+
case 10 /* November */:
|
|
249
|
+
return 30;
|
|
250
|
+
default:
|
|
251
|
+
return 31;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Returns current month and year based on local time zone
|
|
256
|
+
* @nosideeffects
|
|
257
|
+
*/
|
|
258
|
+
TuiMonth.currentLocal = function () {
|
|
259
|
+
var nativeDate = new Date();
|
|
260
|
+
return new TuiMonth(nativeDate.getFullYear(), nativeDate.getMonth());
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Returns current month and year based on UTC
|
|
264
|
+
*/
|
|
265
|
+
TuiMonth.currentUtc = function () {
|
|
266
|
+
var nativeDate = new Date();
|
|
267
|
+
return new TuiMonth(nativeDate.getUTCFullYear(), nativeDate.getUTCMonth());
|
|
268
|
+
};
|
|
269
|
+
TuiMonth.lengthBetween = function (from, to) {
|
|
270
|
+
var absoluteFrom = from.month + from.year * 12;
|
|
271
|
+
var absoluteTo = to.month + to.year * 12;
|
|
272
|
+
return absoluteTo - absoluteFrom;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Normalizes number by clamping it between min and max month
|
|
276
|
+
*/
|
|
277
|
+
TuiMonth.normalizeMonthPart = function (month) {
|
|
278
|
+
return normalizeToIntNumber(month, MIN_MONTH, MAX_MONTH);
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Tests month for validity
|
|
282
|
+
*/
|
|
283
|
+
TuiMonth.isValidMonthPart = function (month) {
|
|
284
|
+
return Number.isInteger(month) && inRange(month, MIN_MONTH, MAX_MONTH + 1);
|
|
285
|
+
};
|
|
231
286
|
Object.defineProperty(TuiMonth.prototype, "formattedMonthPart", {
|
|
232
287
|
get: function () {
|
|
233
288
|
return padStart((this.month + 1).toString(), 2, '0');
|
|
@@ -353,61 +408,6 @@ var TuiMonth = /** @class */ (function (_super) {
|
|
|
353
408
|
TuiMonth.prototype.toUtcNativeDate = function () {
|
|
354
409
|
return new Date(Date.UTC(this.year, this.month));
|
|
355
410
|
};
|
|
356
|
-
/**
|
|
357
|
-
* Tests month and year for validity
|
|
358
|
-
*/
|
|
359
|
-
TuiMonth.isValidMonth = function (year, month) {
|
|
360
|
-
return TuiYear.isValidYear(year) && TuiMonth.isValidMonthPart(month);
|
|
361
|
-
};
|
|
362
|
-
/**
|
|
363
|
-
* Returns number of days in a month
|
|
364
|
-
*/
|
|
365
|
-
TuiMonth.getMonthDaysCount = function (month, isLeapYear) {
|
|
366
|
-
tuiAssert.assert(TuiMonth.isValidMonthPart(month));
|
|
367
|
-
switch (month) {
|
|
368
|
-
case 1 /* February */:
|
|
369
|
-
return isLeapYear ? 29 : 28;
|
|
370
|
-
case 3 /* April */:
|
|
371
|
-
case 5 /* June */:
|
|
372
|
-
case 8 /* September */:
|
|
373
|
-
case 10 /* November */:
|
|
374
|
-
return 30;
|
|
375
|
-
default:
|
|
376
|
-
return 31;
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* Returns current month and year based on local time zone
|
|
381
|
-
* @nosideeffects
|
|
382
|
-
*/
|
|
383
|
-
TuiMonth.currentLocal = function () {
|
|
384
|
-
var nativeDate = new Date();
|
|
385
|
-
return new TuiMonth(nativeDate.getFullYear(), nativeDate.getMonth());
|
|
386
|
-
};
|
|
387
|
-
/**
|
|
388
|
-
* Returns current month and year based on UTC
|
|
389
|
-
*/
|
|
390
|
-
TuiMonth.currentUtc = function () {
|
|
391
|
-
var nativeDate = new Date();
|
|
392
|
-
return new TuiMonth(nativeDate.getUTCFullYear(), nativeDate.getUTCMonth());
|
|
393
|
-
};
|
|
394
|
-
TuiMonth.lengthBetween = function (from, to) {
|
|
395
|
-
var absoluteFrom = from.month + from.year * 12;
|
|
396
|
-
var absoluteTo = to.month + to.year * 12;
|
|
397
|
-
return absoluteTo - absoluteFrom;
|
|
398
|
-
};
|
|
399
|
-
/**
|
|
400
|
-
* Normalizes number by clamping it between min and max month
|
|
401
|
-
*/
|
|
402
|
-
TuiMonth.normalizeMonthPart = function (month) {
|
|
403
|
-
return normalizeToIntNumber(month, MIN_MONTH, MAX_MONTH);
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* Tests month for validity
|
|
407
|
-
*/
|
|
408
|
-
TuiMonth.isValidMonthPart = function (month) {
|
|
409
|
-
return Number.isInteger(month) && inRange(month, MIN_MONTH, MAX_MONTH + 1);
|
|
410
|
-
};
|
|
411
411
|
return TuiMonth;
|
|
412
412
|
}(TuiYear));
|
|
413
413
|
|
|
@@ -423,169 +423,17 @@ var TuiDay = /** @class */ (function (_super) {
|
|
|
423
423
|
tuiAssert.assert(TuiDay.isValidDay(year, month, day));
|
|
424
424
|
return _this;
|
|
425
425
|
}
|
|
426
|
-
Object.defineProperty(TuiDay.prototype, "formattedDayPart", {
|
|
427
|
-
get: function () {
|
|
428
|
-
return padStart(this.day.toString(), 2, '0');
|
|
429
|
-
},
|
|
430
|
-
enumerable: true,
|
|
431
|
-
configurable: true
|
|
432
|
-
});
|
|
433
|
-
Object.defineProperty(TuiDay.prototype, "formattedDay", {
|
|
434
|
-
/**
|
|
435
|
-
* Formatted whole date
|
|
436
|
-
*/
|
|
437
|
-
get: function () {
|
|
438
|
-
return this.formattedDayPart + "." + this.formattedMonth;
|
|
439
|
-
},
|
|
440
|
-
enumerable: true,
|
|
441
|
-
configurable: true
|
|
442
|
-
});
|
|
443
|
-
Object.defineProperty(TuiDay.prototype, "isWeekend", {
|
|
444
|
-
get: function () {
|
|
445
|
-
var dayOfWeek = this.dayOfWeek(false);
|
|
446
|
-
return dayOfWeek === 6 /* Saturday */ || dayOfWeek === 0 /* Sunday */;
|
|
447
|
-
},
|
|
448
|
-
enumerable: true,
|
|
449
|
-
configurable: true
|
|
450
|
-
});
|
|
451
426
|
/**
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* @param startFromMonday whether week starts from Monday and not from Sunday
|
|
455
|
-
* @return day of week (from 0 to 6)
|
|
427
|
+
* Creates {@link TuiDay} from native {@link Date} based on local time zone
|
|
456
428
|
*/
|
|
457
|
-
TuiDay.
|
|
458
|
-
|
|
459
|
-
var dayOfWeek = startFromMonday
|
|
460
|
-
? this.toLocalNativeDate().getDay() - 1
|
|
461
|
-
: this.toLocalNativeDate().getDay();
|
|
462
|
-
return dayOfWeek < 0 ? 6 : dayOfWeek;
|
|
429
|
+
TuiDay.fromLocalNativeDate = function (date) {
|
|
430
|
+
return new TuiDay(date.getFullYear(), date.getMonth(), date.getDate());
|
|
463
431
|
};
|
|
464
432
|
/**
|
|
465
|
-
*
|
|
433
|
+
* Creates {@link TuiDay} from native {@link Date} using UTC
|
|
466
434
|
*/
|
|
467
|
-
TuiDay.
|
|
468
|
-
return (
|
|
469
|
-
(this.monthSame(another) && this.day < another.day));
|
|
470
|
-
};
|
|
471
|
-
/**
|
|
472
|
-
* Passed date is after or equals to current
|
|
473
|
-
*/
|
|
474
|
-
TuiDay.prototype.daySameOrBefore = function (another) {
|
|
475
|
-
return (this.monthBefore(another) ||
|
|
476
|
-
(this.monthSame(another) && this.day <= another.day));
|
|
477
|
-
};
|
|
478
|
-
/**
|
|
479
|
-
* Passed date is the same as current
|
|
480
|
-
*/
|
|
481
|
-
TuiDay.prototype.daySame = function (another) {
|
|
482
|
-
return this.monthSame(another) && this.day === another.day;
|
|
483
|
-
};
|
|
484
|
-
/**
|
|
485
|
-
* Passed date is either before or the same as current
|
|
486
|
-
*/
|
|
487
|
-
TuiDay.prototype.daySameOrAfter = function (another) {
|
|
488
|
-
return (this.monthAfter(another) ||
|
|
489
|
-
(this.monthSame(another) && this.day >= another.day));
|
|
490
|
-
};
|
|
491
|
-
/**
|
|
492
|
-
* Passed date is before current
|
|
493
|
-
*/
|
|
494
|
-
TuiDay.prototype.dayAfter = function (another) {
|
|
495
|
-
return (this.monthAfter(another) ||
|
|
496
|
-
(this.monthSame(another) && this.day > another.day));
|
|
497
|
-
};
|
|
498
|
-
/**
|
|
499
|
-
* Clamping date between two limits
|
|
500
|
-
*
|
|
501
|
-
* @param min
|
|
502
|
-
* @param max
|
|
503
|
-
* @return clamped date
|
|
504
|
-
*/
|
|
505
|
-
TuiDay.prototype.dayLimit = function (min, max) {
|
|
506
|
-
if (min !== null && this.dayBefore(min)) {
|
|
507
|
-
return min;
|
|
508
|
-
}
|
|
509
|
-
if (max !== null && this.dayAfter(max)) {
|
|
510
|
-
return max;
|
|
511
|
-
}
|
|
512
|
-
return this;
|
|
513
|
-
};
|
|
514
|
-
// TODO: Consider removing `backwards` option
|
|
515
|
-
/**
|
|
516
|
-
* Immutably alters current day by passed offset
|
|
517
|
-
*
|
|
518
|
-
* If resulting month has more days than original one, date is rounded to the maximum day
|
|
519
|
-
* in the resulting month. Offset of days will be calculated based on the resulted year and month
|
|
520
|
-
* to not interfere with parent classes methods
|
|
521
|
-
*
|
|
522
|
-
* @param offset
|
|
523
|
-
* @param backwards shift date backwards
|
|
524
|
-
* @return new date object as a result of offsetting current
|
|
525
|
-
*/
|
|
526
|
-
TuiDay.prototype.append = function (_a, backwards) {
|
|
527
|
-
var _b = _a.year, year = _b === void 0 ? 0 : _b, _c = _a.month, month = _c === void 0 ? 0 : _c, _d = _a.day, day = _d === void 0 ? 0 : _d;
|
|
528
|
-
if (backwards === void 0) { backwards = false; }
|
|
529
|
-
if (backwards) {
|
|
530
|
-
year *= -1;
|
|
531
|
-
month *= -1;
|
|
532
|
-
day *= -1;
|
|
533
|
-
}
|
|
534
|
-
var totalMonths = (this.year + year) * MONTHS_IN_YEAR + this.month + month;
|
|
535
|
-
var years = Math.floor(totalMonths / MONTHS_IN_YEAR);
|
|
536
|
-
var months = totalMonths % MONTHS_IN_YEAR;
|
|
537
|
-
var days = Math.min(this.day, TuiMonth.getMonthDaysCount(months, TuiYear.isLeapYear(years))) + day;
|
|
538
|
-
while (days > TuiMonth.getMonthDaysCount(months, TuiYear.isLeapYear(years))) {
|
|
539
|
-
days -= TuiMonth.getMonthDaysCount(months, TuiYear.isLeapYear(years));
|
|
540
|
-
if (months === 11 /* December */) {
|
|
541
|
-
years++;
|
|
542
|
-
months = 0 /* January */;
|
|
543
|
-
}
|
|
544
|
-
else {
|
|
545
|
-
months++;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
while (days < MIN_DAY) {
|
|
549
|
-
if (months === 0 /* January */) {
|
|
550
|
-
years--;
|
|
551
|
-
months = 11 /* December */;
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
months--;
|
|
555
|
-
}
|
|
556
|
-
days += TuiMonth.getMonthDaysCount(months, TuiYear.isLeapYear(years));
|
|
557
|
-
}
|
|
558
|
-
return new TuiDay(years, months, days);
|
|
559
|
-
};
|
|
560
|
-
TuiDay.prototype.toString = function () {
|
|
561
|
-
return this.formattedDay;
|
|
562
|
-
};
|
|
563
|
-
TuiDay.prototype.toJSON = function () {
|
|
564
|
-
return _super.prototype.toJSON.call(this) + "-" + this.formattedDayPart;
|
|
565
|
-
};
|
|
566
|
-
/**
|
|
567
|
-
* Returns native {@link Date} based on local time zone
|
|
568
|
-
*/
|
|
569
|
-
TuiDay.prototype.toLocalNativeDate = function () {
|
|
570
|
-
return new Date(this.year, this.month, this.day);
|
|
571
|
-
};
|
|
572
|
-
/**
|
|
573
|
-
* Returns native {@link Date} based on UTC
|
|
574
|
-
*/
|
|
575
|
-
TuiDay.prototype.toUtcNativeDate = function () {
|
|
576
|
-
return new Date(Date.UTC(this.year, this.month, this.day));
|
|
577
|
-
};
|
|
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());
|
|
435
|
+
TuiDay.fromUtcNativeDate = function (date) {
|
|
436
|
+
return new TuiDay(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
589
437
|
};
|
|
590
438
|
/**
|
|
591
439
|
* Check validity of year, month and day
|
|
@@ -694,6 +542,158 @@ var TuiDay = /** @class */ (function (_super) {
|
|
|
694
542
|
var monthDaysCount = TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year));
|
|
695
543
|
return normalizeToIntNumber(day, 1, monthDaysCount);
|
|
696
544
|
};
|
|
545
|
+
Object.defineProperty(TuiDay.prototype, "formattedDayPart", {
|
|
546
|
+
get: function () {
|
|
547
|
+
return padStart(this.day.toString(), 2, '0');
|
|
548
|
+
},
|
|
549
|
+
enumerable: true,
|
|
550
|
+
configurable: true
|
|
551
|
+
});
|
|
552
|
+
Object.defineProperty(TuiDay.prototype, "formattedDay", {
|
|
553
|
+
/**
|
|
554
|
+
* Formatted whole date
|
|
555
|
+
*/
|
|
556
|
+
get: function () {
|
|
557
|
+
return this.formattedDayPart + "." + this.formattedMonth;
|
|
558
|
+
},
|
|
559
|
+
enumerable: true,
|
|
560
|
+
configurable: true
|
|
561
|
+
});
|
|
562
|
+
Object.defineProperty(TuiDay.prototype, "isWeekend", {
|
|
563
|
+
get: function () {
|
|
564
|
+
var dayOfWeek = this.dayOfWeek(false);
|
|
565
|
+
return dayOfWeek === 6 /* Saturday */ || dayOfWeek === 0 /* Sunday */;
|
|
566
|
+
},
|
|
567
|
+
enumerable: true,
|
|
568
|
+
configurable: true
|
|
569
|
+
});
|
|
570
|
+
/**
|
|
571
|
+
* Returns day of week
|
|
572
|
+
*
|
|
573
|
+
* @param startFromMonday whether week starts from Monday and not from Sunday
|
|
574
|
+
* @return day of week (from 0 to 6)
|
|
575
|
+
*/
|
|
576
|
+
TuiDay.prototype.dayOfWeek = function (startFromMonday) {
|
|
577
|
+
if (startFromMonday === void 0) { startFromMonday = true; }
|
|
578
|
+
var dayOfWeek = startFromMonday
|
|
579
|
+
? this.toLocalNativeDate().getDay() - 1
|
|
580
|
+
: this.toLocalNativeDate().getDay();
|
|
581
|
+
return dayOfWeek < 0 ? 6 : dayOfWeek;
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* Passed date is after current
|
|
585
|
+
*/
|
|
586
|
+
TuiDay.prototype.dayBefore = function (another) {
|
|
587
|
+
return (this.monthBefore(another) ||
|
|
588
|
+
(this.monthSame(another) && this.day < another.day));
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* Passed date is after or equals to current
|
|
592
|
+
*/
|
|
593
|
+
TuiDay.prototype.daySameOrBefore = function (another) {
|
|
594
|
+
return (this.monthBefore(another) ||
|
|
595
|
+
(this.monthSame(another) && this.day <= another.day));
|
|
596
|
+
};
|
|
597
|
+
/**
|
|
598
|
+
* Passed date is the same as current
|
|
599
|
+
*/
|
|
600
|
+
TuiDay.prototype.daySame = function (another) {
|
|
601
|
+
return this.monthSame(another) && this.day === another.day;
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* Passed date is either before or the same as current
|
|
605
|
+
*/
|
|
606
|
+
TuiDay.prototype.daySameOrAfter = function (another) {
|
|
607
|
+
return (this.monthAfter(another) ||
|
|
608
|
+
(this.monthSame(another) && this.day >= another.day));
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* Passed date is before current
|
|
612
|
+
*/
|
|
613
|
+
TuiDay.prototype.dayAfter = function (another) {
|
|
614
|
+
return (this.monthAfter(another) ||
|
|
615
|
+
(this.monthSame(another) && this.day > another.day));
|
|
616
|
+
};
|
|
617
|
+
/**
|
|
618
|
+
* Clamping date between two limits
|
|
619
|
+
*
|
|
620
|
+
* @param min
|
|
621
|
+
* @param max
|
|
622
|
+
* @return clamped date
|
|
623
|
+
*/
|
|
624
|
+
TuiDay.prototype.dayLimit = function (min, max) {
|
|
625
|
+
if (min !== null && this.dayBefore(min)) {
|
|
626
|
+
return min;
|
|
627
|
+
}
|
|
628
|
+
if (max !== null && this.dayAfter(max)) {
|
|
629
|
+
return max;
|
|
630
|
+
}
|
|
631
|
+
return this;
|
|
632
|
+
};
|
|
633
|
+
// TODO: Consider removing `backwards` option
|
|
634
|
+
/**
|
|
635
|
+
* Immutably alters current day by passed offset
|
|
636
|
+
*
|
|
637
|
+
* If resulting month has more days than original one, date is rounded to the maximum day
|
|
638
|
+
* in the resulting month. Offset of days will be calculated based on the resulted year and month
|
|
639
|
+
* to not interfere with parent classes methods
|
|
640
|
+
*
|
|
641
|
+
* @param offset
|
|
642
|
+
* @param backwards shift date backwards
|
|
643
|
+
* @return new date object as a result of offsetting current
|
|
644
|
+
*/
|
|
645
|
+
TuiDay.prototype.append = function (_a, backwards) {
|
|
646
|
+
var _b = _a.year, year = _b === void 0 ? 0 : _b, _c = _a.month, month = _c === void 0 ? 0 : _c, _d = _a.day, day = _d === void 0 ? 0 : _d;
|
|
647
|
+
if (backwards === void 0) { backwards = false; }
|
|
648
|
+
if (backwards) {
|
|
649
|
+
year *= -1;
|
|
650
|
+
month *= -1;
|
|
651
|
+
day *= -1;
|
|
652
|
+
}
|
|
653
|
+
var totalMonths = (this.year + year) * MONTHS_IN_YEAR + this.month + month;
|
|
654
|
+
var years = Math.floor(totalMonths / MONTHS_IN_YEAR);
|
|
655
|
+
var months = totalMonths % MONTHS_IN_YEAR;
|
|
656
|
+
var days = Math.min(this.day, TuiMonth.getMonthDaysCount(months, TuiYear.isLeapYear(years))) + day;
|
|
657
|
+
while (days > TuiMonth.getMonthDaysCount(months, TuiYear.isLeapYear(years))) {
|
|
658
|
+
days -= TuiMonth.getMonthDaysCount(months, TuiYear.isLeapYear(years));
|
|
659
|
+
if (months === 11 /* December */) {
|
|
660
|
+
years++;
|
|
661
|
+
months = 0 /* January */;
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
months++;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
while (days < MIN_DAY) {
|
|
668
|
+
if (months === 0 /* January */) {
|
|
669
|
+
years--;
|
|
670
|
+
months = 11 /* December */;
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
months--;
|
|
674
|
+
}
|
|
675
|
+
days += TuiMonth.getMonthDaysCount(months, TuiYear.isLeapYear(years));
|
|
676
|
+
}
|
|
677
|
+
return new TuiDay(years, months, days);
|
|
678
|
+
};
|
|
679
|
+
TuiDay.prototype.toString = function () {
|
|
680
|
+
return this.formattedDay;
|
|
681
|
+
};
|
|
682
|
+
TuiDay.prototype.toJSON = function () {
|
|
683
|
+
return _super.prototype.toJSON.call(this) + "-" + this.formattedDayPart;
|
|
684
|
+
};
|
|
685
|
+
/**
|
|
686
|
+
* Returns native {@link Date} based on local time zone
|
|
687
|
+
*/
|
|
688
|
+
TuiDay.prototype.toLocalNativeDate = function () {
|
|
689
|
+
return new Date(this.year, this.month, this.day);
|
|
690
|
+
};
|
|
691
|
+
/**
|
|
692
|
+
* Returns native {@link Date} based on UTC
|
|
693
|
+
*/
|
|
694
|
+
TuiDay.prototype.toUtcNativeDate = function () {
|
|
695
|
+
return new Date(Date.UTC(this.year, this.month, this.day));
|
|
696
|
+
};
|
|
697
697
|
return TuiDay;
|
|
698
698
|
}(TuiMonth));
|
|
699
699
|
|
|
@@ -706,6 +706,11 @@ var TuiMonthRange = /** @class */ (function () {
|
|
|
706
706
|
this.to = to;
|
|
707
707
|
tuiAssert.assert(from.monthSameOrBefore(to));
|
|
708
708
|
}
|
|
709
|
+
TuiMonthRange.sort = function (month1, month2) {
|
|
710
|
+
return month1.monthSameOrBefore(month2)
|
|
711
|
+
? new TuiMonthRange(month1, month2)
|
|
712
|
+
: new TuiMonthRange(month2, month1);
|
|
713
|
+
};
|
|
709
714
|
Object.defineProperty(TuiMonthRange.prototype, "isSingleMonth", {
|
|
710
715
|
get: function () {
|
|
711
716
|
return this.from.monthSame(this.to);
|
|
@@ -726,11 +731,6 @@ var TuiMonthRange = /** @class */ (function () {
|
|
|
726
731
|
TuiMonthRange.prototype.toString = function () {
|
|
727
732
|
return "" + this.from + RANGE_SEPARATOR_CHAR + this.to;
|
|
728
733
|
};
|
|
729
|
-
TuiMonthRange.sort = function (month1, month2) {
|
|
730
|
-
return month1.monthSameOrBefore(month2)
|
|
731
|
-
? new TuiMonthRange(month1, month2)
|
|
732
|
-
: new TuiMonthRange(month2, month1);
|
|
733
|
-
};
|
|
734
734
|
return TuiMonthRange;
|
|
735
735
|
}());
|
|
736
736
|
|
|
@@ -746,6 +746,31 @@ var TuiDayRange = /** @class */ (function (_super) {
|
|
|
746
746
|
tuiAssert.assert(from.daySameOrBefore(to));
|
|
747
747
|
return _this;
|
|
748
748
|
}
|
|
749
|
+
/**
|
|
750
|
+
* Creates range from two days after sorting them
|
|
751
|
+
*
|
|
752
|
+
* @param day1
|
|
753
|
+
* @param day2
|
|
754
|
+
* @return new range with sorted days
|
|
755
|
+
*/
|
|
756
|
+
TuiDayRange.sort = function (day1, day2) {
|
|
757
|
+
return day1.daySameOrBefore(day2)
|
|
758
|
+
? new TuiDayRange(day1, day2)
|
|
759
|
+
: new TuiDayRange(day2, day1);
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* Parse and correct a day range in string format
|
|
763
|
+
*
|
|
764
|
+
* @param rangeString a string of dates in a format dd.mm.yyyy - dd.mm.yyyy
|
|
765
|
+
* @return normalized day range object
|
|
766
|
+
*/
|
|
767
|
+
TuiDayRange.normalizeParse = function (rangeString) {
|
|
768
|
+
var leftDay = TuiDay.normalizeParse(rangeString.slice(0, DATE_FILLER_LENGTH));
|
|
769
|
+
if (rangeString.length < DATE_RANGE_FILLER_LENGTH) {
|
|
770
|
+
return new TuiDayRange(leftDay, leftDay);
|
|
771
|
+
}
|
|
772
|
+
return TuiDayRange.sort(leftDay, TuiDay.normalizeParse(rangeString.slice(DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length)));
|
|
773
|
+
};
|
|
749
774
|
Object.defineProperty(TuiDayRange.prototype, "isSingleDay", {
|
|
750
775
|
get: function () {
|
|
751
776
|
return this.from.daySame(this.to);
|
|
@@ -782,31 +807,6 @@ var TuiDayRange = /** @class */ (function (_super) {
|
|
|
782
807
|
TuiDayRange.prototype.dayLimit = function (min, max) {
|
|
783
808
|
return new TuiDayRange(this.from.dayLimit(min, max), this.to.dayLimit(min, max));
|
|
784
809
|
};
|
|
785
|
-
/**
|
|
786
|
-
* Creates range from two days after sorting them
|
|
787
|
-
*
|
|
788
|
-
* @param day1
|
|
789
|
-
* @param day2
|
|
790
|
-
* @return new range with sorted days
|
|
791
|
-
*/
|
|
792
|
-
TuiDayRange.sort = function (day1, day2) {
|
|
793
|
-
return day1.daySameOrBefore(day2)
|
|
794
|
-
? new TuiDayRange(day1, day2)
|
|
795
|
-
: new TuiDayRange(day2, day1);
|
|
796
|
-
};
|
|
797
|
-
/**
|
|
798
|
-
* Parse and correct a day range in string format
|
|
799
|
-
*
|
|
800
|
-
* @param rangeString a string of dates in a format dd.mm.yyyy - dd.mm.yyyy
|
|
801
|
-
* @return normalized day range object
|
|
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)));
|
|
809
|
-
};
|
|
810
810
|
return TuiDayRange;
|
|
811
811
|
}(TuiMonthRange));
|
|
812
812
|
|
|
@@ -826,46 +826,6 @@ var TuiTime = /** @class */ (function () {
|
|
|
826
826
|
this.ms = ms;
|
|
827
827
|
tuiAssert.assert(TuiTime.isValidTime(hours, minutes, seconds, ms), 'Time must be real, but got:', hours, minutes, seconds, ms);
|
|
828
828
|
}
|
|
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
829
|
/**
|
|
870
830
|
* Checks if time is valid
|
|
871
831
|
*/
|
|
@@ -924,6 +884,46 @@ var TuiTime = /** @class */ (function () {
|
|
|
924
884
|
TuiTime.fromLocalNativeDate = function (date) {
|
|
925
885
|
return new TuiTime(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
926
886
|
};
|
|
887
|
+
/**
|
|
888
|
+
* Shifts time by hours and minutes
|
|
889
|
+
*/
|
|
890
|
+
TuiTime.prototype.shift = function (_a) {
|
|
891
|
+
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;
|
|
892
|
+
var newMs = (1000 + this.ms + (ms % 1000)) % 1000;
|
|
893
|
+
var secondsInMs = ms < 0 ? Math.ceil(ms / 1000) : Math.floor(ms / 1000);
|
|
894
|
+
var secondsToAdd = secondsInMs + seconds;
|
|
895
|
+
var newSeconds = (60 + this.seconds + (secondsToAdd % 60)) % 60;
|
|
896
|
+
var minutesInSeconds = secondsToAdd < 0
|
|
897
|
+
? Math.ceil(secondsToAdd / 60)
|
|
898
|
+
: Math.floor(secondsToAdd / 60);
|
|
899
|
+
var minutesToAdd = minutesInSeconds + minutes;
|
|
900
|
+
var newMinutes = (60 + this.minutes + (minutesToAdd % 60)) % 60;
|
|
901
|
+
var hoursInMinutes = minutesToAdd < 0
|
|
902
|
+
? Math.ceil(minutesToAdd / 60)
|
|
903
|
+
: Math.floor(minutesToAdd / 60);
|
|
904
|
+
var hoursToAdd = hoursInMinutes + hours;
|
|
905
|
+
var newHours = (24 + this.hours + (hoursToAdd % 24)) % 24;
|
|
906
|
+
return new TuiTime(newHours, newMinutes, newSeconds, newMs);
|
|
907
|
+
};
|
|
908
|
+
/**
|
|
909
|
+
* Converts TuiTime to string
|
|
910
|
+
*/
|
|
911
|
+
TuiTime.prototype.toString = function (mode) {
|
|
912
|
+
var needAddMs = mode === 'HH:MM:SS.MSS' || (!mode && this.ms > 0);
|
|
913
|
+
var needAddSeconds = needAddMs || mode === 'HH:MM:SS' || (!mode && this.seconds > 0);
|
|
914
|
+
return (this.formatTime(this.hours) + ":" + this.formatTime(this.minutes) +
|
|
915
|
+
("" + (needAddSeconds ? ':' + this.formatTime(this.seconds) : '')) +
|
|
916
|
+
("" + (needAddMs ? '.' + this.formatTime(this.ms, 3) : '')));
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* Converts TuiTime to milliseconds
|
|
920
|
+
*/
|
|
921
|
+
TuiTime.prototype.toAbsoluteMilliseconds = function () {
|
|
922
|
+
return (this.hours * MILLISECONDS_IN_HOUR +
|
|
923
|
+
this.minutes * MILLISECONDS_IN_MINUTE +
|
|
924
|
+
this.seconds * 1000 +
|
|
925
|
+
this.ms);
|
|
926
|
+
};
|
|
927
927
|
TuiTime.prototype.formatTime = function (time, digits) {
|
|
928
928
|
if (digits === void 0) { digits = 2; }
|
|
929
929
|
return padStart(time.toString(), digits, '0');
|