@meshmakers/shared-ui 3.4.210 → 3.4.230

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.
@@ -4130,8 +4130,15 @@ class TimeRangeUtils {
4130
4130
  /**
4131
4131
  * Calculate time range for a specific year.
4132
4132
  * Uses exclusive end boundary (start of next year) for correct LESS_THAN filtering.
4133
+ * @param zone Timezone basis for the boundaries (defaults to `'local'`).
4133
4134
  */
4134
- static getYearRange(year) {
4135
+ static getYearRange(year, zone = 'local') {
4136
+ if (zone === 'utc') {
4137
+ return {
4138
+ from: new Date(Date.UTC(year, 0, 1, 0, 0, 0, 0)),
4139
+ to: new Date(Date.UTC(year + 1, 0, 1, 0, 0, 0, 0))
4140
+ };
4141
+ }
4135
4142
  return {
4136
4143
  from: new Date(year, 0, 1, 0, 0, 0, 0),
4137
4144
  to: new Date(year + 1, 0, 1, 0, 0, 0, 0)
@@ -4140,9 +4147,16 @@ class TimeRangeUtils {
4140
4147
  /**
4141
4148
  * Calculate time range for a specific quarter.
4142
4149
  * Uses exclusive end boundary (start of next quarter) for correct LESS_THAN filtering.
4150
+ * @param zone Timezone basis for the boundaries (defaults to `'local'`).
4143
4151
  */
4144
- static getQuarterRange(year, quarter) {
4152
+ static getQuarterRange(year, quarter, zone = 'local') {
4145
4153
  const startMonth = (quarter - 1) * 3;
4154
+ if (zone === 'utc') {
4155
+ return {
4156
+ from: new Date(Date.UTC(year, startMonth, 1, 0, 0, 0, 0)),
4157
+ to: new Date(Date.UTC(year, startMonth + 3, 1, 0, 0, 0, 0))
4158
+ };
4159
+ }
4146
4160
  return {
4147
4161
  from: new Date(year, startMonth, 1, 0, 0, 0, 0),
4148
4162
  to: new Date(year, startMonth + 3, 1, 0, 0, 0, 0)
@@ -4151,8 +4165,15 @@ class TimeRangeUtils {
4151
4165
  /**
4152
4166
  * Calculate time range for a specific month.
4153
4167
  * Uses exclusive end boundary (start of next month) for correct LESS_THAN filtering.
4168
+ * @param zone Timezone basis for the boundaries (defaults to `'local'`).
4154
4169
  */
4155
- static getMonthRange(year, month) {
4170
+ static getMonthRange(year, month, zone = 'local') {
4171
+ if (zone === 'utc') {
4172
+ return {
4173
+ from: new Date(Date.UTC(year, month, 1, 0, 0, 0, 0)),
4174
+ to: new Date(Date.UTC(year, month + 1, 1, 0, 0, 0, 0))
4175
+ };
4176
+ }
4156
4177
  return {
4157
4178
  from: new Date(year, month, 1, 0, 0, 0, 0),
4158
4179
  to: new Date(year, month + 1, 1, 0, 0, 0, 0)
@@ -4164,15 +4185,24 @@ class TimeRangeUtils {
4164
4185
  * Optionally filters to a specific hour range within the day.
4165
4186
  * @param hourFrom Start hour (0-23), defaults to 0
4166
4187
  * @param hourTo End hour (1-24, exclusive), defaults to 24 (= next day 00:00)
4188
+ * @param zone Timezone basis for the boundaries (defaults to `'local'`).
4167
4189
  */
4168
- static getDayRange(year, month, day, hourFrom, hourTo) {
4190
+ static getDayRange(year, month, day, hourFrom, hourTo, zone = 'local') {
4169
4191
  const fromHour = hourFrom ?? 0;
4170
4192
  const toHour = hourTo ?? 24;
4193
+ if (zone === 'utc') {
4194
+ return {
4195
+ from: new Date(Date.UTC(year, month, day, fromHour, 0, 0, 0)),
4196
+ to: toHour === 24
4197
+ ? new Date(Date.UTC(year, month, day + 1, 0, 0, 0, 0))
4198
+ : new Date(Date.UTC(year, month, day, toHour, 0, 0, 0))
4199
+ };
4200
+ }
4171
4201
  return {
4172
- from: new Date(Date.UTC(year, month, day, fromHour, 0, 0, 0)),
4202
+ from: new Date(year, month, day, fromHour, 0, 0, 0),
4173
4203
  to: toHour === 24
4174
- ? new Date(Date.UTC(year, month, day + 1, 0, 0, 0, 0))
4175
- : new Date(Date.UTC(year, month, day, toHour, 0, 0, 0))
4204
+ ? new Date(year, month, day + 1, 0, 0, 0, 0)
4205
+ : new Date(year, month, day, toHour, 0, 0, 0)
4176
4206
  };
4177
4207
  }
4178
4208
  /**
@@ -4201,28 +4231,30 @@ class TimeRangeUtils {
4201
4231
  * Calculate time range from selection.
4202
4232
  * @param selection The current selection state
4203
4233
  * @param showTime If false (default), custom date ranges are normalized to full-day boundaries
4204
- * with exclusive end (from: 00:00:00 UTC, to: start of next day 00:00:00 UTC)
4234
+ * with exclusive end (from: 00:00:00, to: start of next day 00:00:00)
4235
+ * @param zone Timezone basis for calendar boundaries (defaults to `'local'`). Applies to
4236
+ * year/quarter/month/day and normalized custom ranges; relative ranges ignore it.
4205
4237
  */
4206
- static getTimeRangeFromSelection(selection, showTime = false) {
4238
+ static getTimeRangeFromSelection(selection, showTime = false, zone = 'local') {
4207
4239
  switch (selection.type) {
4208
4240
  case 'year':
4209
4241
  if (selection.year) {
4210
- return this.getYearRange(selection.year);
4242
+ return this.getYearRange(selection.year, zone);
4211
4243
  }
4212
4244
  break;
4213
4245
  case 'quarter':
4214
4246
  if (selection.year && selection.quarter) {
4215
- return this.getQuarterRange(selection.year, selection.quarter);
4247
+ return this.getQuarterRange(selection.year, selection.quarter, zone);
4216
4248
  }
4217
4249
  break;
4218
4250
  case 'month':
4219
4251
  if (selection.year && selection.month !== undefined) {
4220
- return this.getMonthRange(selection.year, selection.month);
4252
+ return this.getMonthRange(selection.year, selection.month, zone);
4221
4253
  }
4222
4254
  break;
4223
4255
  case 'day':
4224
4256
  if (selection.year && selection.month !== undefined && selection.day !== undefined) {
4225
- return this.getDayRange(selection.year, selection.month, selection.day, selection.hourFrom, selection.hourTo);
4257
+ return this.getDayRange(selection.year, selection.month, selection.day, selection.hourFrom, selection.hourTo, zone);
4226
4258
  }
4227
4259
  break;
4228
4260
  case 'relative':
@@ -4239,12 +4271,19 @@ class TimeRangeUtils {
4239
4271
  to: selection.customTo
4240
4272
  };
4241
4273
  }
4242
- // Normalize to full-day boundaries in UTC (exclusive end, like year/quarter/month)
4274
+ // Normalize to full-day boundaries (exclusive end, like year/quarter/month)
4243
4275
  const from = new Date(selection.customFrom);
4244
- from.setUTCHours(0, 0, 0, 0);
4245
4276
  const to = new Date(selection.customTo);
4246
- to.setUTCHours(0, 0, 0, 0);
4247
- to.setUTCDate(to.getUTCDate() + 1);
4277
+ if (zone === 'utc') {
4278
+ from.setUTCHours(0, 0, 0, 0);
4279
+ to.setUTCHours(0, 0, 0, 0);
4280
+ to.setUTCDate(to.getUTCDate() + 1);
4281
+ }
4282
+ else {
4283
+ from.setHours(0, 0, 0, 0);
4284
+ to.setHours(0, 0, 0, 0);
4285
+ to.setDate(to.getDate() + 1);
4286
+ }
4248
4287
  return { from, to };
4249
4288
  }
4250
4289
  break;