@naturalcycles/js-lib 14.99.1 → 14.99.2

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.
@@ -25,15 +25,12 @@ export interface LocalTimeComponents {
25
25
  */
26
26
  export declare class LocalTime {
27
27
  private $date;
28
- utcMode: boolean;
29
28
  private constructor();
30
29
  /**
31
30
  * Parses input String into LocalDate.
32
31
  * Input can already be a LocalDate - it is returned as-is in that case.
33
32
  */
34
33
  static of(d: LocalTimeConfig): LocalTime;
35
- utc(): this;
36
- local(): this;
37
34
  /**
38
35
  * Returns null if invalid
39
36
  */
@@ -25,9 +25,8 @@ const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7]);
25
25
  * @experimental
26
26
  */
27
27
  class LocalTime {
28
- constructor($date, utcMode) {
28
+ constructor($date) {
29
29
  this.$date = $date;
30
- this.utcMode = utcMode;
31
30
  }
32
31
  /**
33
32
  * Parses input String into LocalDate.
@@ -40,14 +39,6 @@ class LocalTime {
40
39
  }
41
40
  return t;
42
41
  }
43
- utc() {
44
- this.utcMode = true;
45
- return this;
46
- }
47
- local() {
48
- this.utcMode = false;
49
- return this;
50
- }
51
42
  /**
52
43
  * Returns null if invalid
53
44
  */
@@ -74,7 +65,7 @@ class LocalTime {
74
65
  // if (utc) {
75
66
  // date.setMinutes(date.getMinutes() + date.getTimezoneOffset())
76
67
  // }
77
- return new LocalTime(date, false);
68
+ return new LocalTime(date);
78
69
  }
79
70
  static parseToDate(d) {
80
71
  if (d instanceof LocalTime)
@@ -102,58 +93,56 @@ class LocalTime {
102
93
  return this.parseOrNull(d) !== null;
103
94
  }
104
95
  static now() {
105
- return new LocalTime(new Date(), false);
96
+ return new LocalTime(new Date());
106
97
  }
107
98
  static fromComponents(c) {
108
- return new LocalTime(new Date(c.year, c.month - 1, c.day, c.hour, c.minute, c.second), false);
99
+ return new LocalTime(new Date(c.year, c.month - 1, c.day, c.hour, c.minute, c.second));
109
100
  }
110
101
  get(unit) {
111
102
  if (unit === 'year') {
112
- return this.utcMode ? this.$date.getUTCFullYear() : this.$date.getFullYear();
103
+ return this.$date.getFullYear();
113
104
  }
114
105
  if (unit === 'month') {
115
- return (this.utcMode ? this.$date.getUTCMonth() : this.$date.getMonth()) + 1;
106
+ return this.$date.getMonth() + 1;
116
107
  }
117
108
  if (unit === 'day') {
118
- return this.utcMode ? this.$date.getUTCDate() : this.$date.getDate();
109
+ return this.$date.getDate();
119
110
  }
120
111
  if (unit === 'hour') {
121
- return this.utcMode ? this.$date.getUTCHours() : this.$date.getHours();
112
+ return this.$date.getHours();
122
113
  }
123
114
  if (unit === 'minute') {
124
- return this.utcMode ? this.$date.getUTCMinutes() : this.$date.getMinutes();
115
+ return this.$date.getMinutes();
125
116
  }
126
117
  if (unit === 'week') {
127
118
  return getWeek(this.$date);
128
119
  }
129
120
  // second
130
- return this.utcMode ? this.$date.getUTCSeconds() : this.$date.getSeconds();
121
+ return this.$date.getSeconds();
131
122
  }
132
123
  set(unit, v, mutate = false) {
133
124
  const t = mutate ? this : this.clone();
134
- /* eslint-disable @typescript-eslint/no-unused-expressions */
135
125
  if (unit === 'year') {
136
- this.utcMode ? t.$date.setUTCFullYear(v) : t.$date.setFullYear(v);
126
+ t.$date.setFullYear(v);
137
127
  }
138
128
  else if (unit === 'month') {
139
- this.utcMode ? t.$date.setUTCMonth(v - 1) : t.$date.setMonth(v - 1);
129
+ t.$date.setMonth(v - 1);
140
130
  }
141
131
  else if (unit === 'day') {
142
- this.utcMode ? t.$date.setUTCDate(v) : t.$date.setDate(v);
132
+ t.$date.setDate(v);
143
133
  }
144
134
  else if (unit === 'hour') {
145
- this.utcMode ? t.$date.setUTCHours(v) : t.$date.setHours(v);
135
+ t.$date.setHours(v);
146
136
  }
147
137
  else if (unit === 'minute') {
148
- this.utcMode ? t.$date.setUTCMinutes(v) : t.$date.setMinutes(v);
138
+ t.$date.setMinutes(v);
149
139
  }
150
140
  else if (unit === 'second') {
151
- this.utcMode ? t.$date.setUTCSeconds(v) : t.$date.setSeconds(v);
141
+ t.$date.setSeconds(v);
152
142
  }
153
143
  else if (unit === 'week') {
154
144
  setWeek(t.$date, v, true);
155
145
  }
156
- /* eslint-enable @typescript-eslint/no-unused-expressions */
157
146
  return t;
158
147
  }
159
148
  year(v) {
@@ -188,27 +177,25 @@ class LocalTime {
188
177
  }
189
178
  setComponents(c, mutate = false) {
190
179
  const d = mutate ? this.$date : new Date(this.$date);
191
- /* eslint-disable @typescript-eslint/no-unused-expressions */
192
180
  if (c.year) {
193
- this.utcMode ? d.setUTCFullYear(c.year) : d.setFullYear(c.year);
181
+ d.setFullYear(c.year);
194
182
  }
195
183
  if (c.month) {
196
- this.utcMode ? d.setUTCMonth(c.month - 1) : d.setMonth(c.month - 1);
184
+ d.setMonth(c.month - 1);
197
185
  }
198
186
  if (c.day) {
199
- this.utcMode ? d.setUTCDate(c.day) : d.setDate(c.day);
187
+ d.setDate(c.day);
200
188
  }
201
189
  if (c.hour !== undefined) {
202
- this.utcMode ? d.setUTCHours(c.hour) : d.setHours(c.hour);
190
+ d.setHours(c.hour);
203
191
  }
204
192
  if (c.minute !== undefined) {
205
- this.utcMode ? d.setUTCMinutes(c.minute) : d.setMinutes(c.minute);
193
+ d.setMinutes(c.minute);
206
194
  }
207
195
  if (c.second !== undefined) {
208
- this.utcMode ? d.setUTCSeconds(c.second) : d.setSeconds(c.second);
196
+ d.setSeconds(c.second);
209
197
  }
210
- /* eslint-enable @typescript-eslint/no-unused-expressions */
211
- return mutate ? this : new LocalTime(d, this.utcMode);
198
+ return mutate ? this : new LocalTime(d);
212
199
  }
213
200
  add(num, unit, mutate = false) {
214
201
  if (unit === 'week') {
@@ -278,19 +265,18 @@ class LocalTime {
278
265
  return this;
279
266
  const d = mutate ? this.$date : new Date(this.$date);
280
267
  d.setSeconds(0, 0);
281
- /* eslint-disable @typescript-eslint/no-unused-expressions */
282
268
  if (unit !== 'minute') {
283
- this.utcMode ? d.setUTCMinutes(0) : d.setMinutes(0);
269
+ d.setMinutes(0);
284
270
  if (unit !== 'hour') {
285
- this.utcMode ? d.setUTCHours(0) : d.setHours(0);
271
+ d.setHours(0);
286
272
  if (unit !== 'day') {
287
273
  // year, month or week
288
274
  if (unit === 'year') {
289
- this.utcMode ? d.setUTCMonth(0) : d.setMonth(0);
290
- this.utcMode ? d.setUTCDate(1) : d.setDate(1);
275
+ d.setMonth(0);
276
+ d.setDate(1);
291
277
  }
292
278
  else if (unit === 'month') {
293
- this.utcMode ? d.setUTCDate(1) : d.setDate(1);
279
+ d.setDate(1);
294
280
  }
295
281
  else {
296
282
  // week
@@ -299,23 +285,21 @@ class LocalTime {
299
285
  }
300
286
  }
301
287
  }
302
- /* eslint-enable @typescript-eslint/no-unused-expressions */
303
- return mutate ? this : new LocalTime(d, this.utcMode);
288
+ return mutate ? this : new LocalTime(d);
304
289
  }
305
290
  endOf(unit, mutate = false) {
306
291
  if (unit === 'second')
307
292
  return this;
308
293
  const d = mutate ? this.$date : new Date(this.$date);
309
294
  d.setSeconds(59, 0);
310
- /* eslint-disable @typescript-eslint/no-unused-expressions */
311
295
  if (unit !== 'minute') {
312
- this.utcMode ? d.setUTCMinutes(59) : d.setMinutes(59);
296
+ d.setMinutes(59);
313
297
  if (unit !== 'hour') {
314
- this.utcMode ? d.setUTCHours(23) : d.setHours(23);
298
+ d.setHours(23);
315
299
  if (unit !== 'day') {
316
300
  // year, month or week
317
301
  if (unit === 'year') {
318
- this.utcMode ? d.setUTCMonth(11) : d.setMonth(11);
302
+ d.setMonth(11);
319
303
  }
320
304
  if (unit === 'week') {
321
305
  endOfWeek(d, true);
@@ -323,13 +307,12 @@ class LocalTime {
323
307
  else {
324
308
  // year or month
325
309
  const lastDay = localDate_1.LocalDate.getMonthLength(d.getFullYear(), d.getMonth() + 1);
326
- this.utcMode ? d.setUTCDate(lastDay) : d.setDate(lastDay);
310
+ d.setDate(lastDay);
327
311
  }
328
312
  }
329
313
  }
330
314
  }
331
- /* eslint-enable @typescript-eslint/no-unused-expressions */
332
- return mutate ? this : new LocalTime(d, this.utcMode);
315
+ return mutate ? this : new LocalTime(d);
333
316
  }
334
317
  static sort(items, mutate = false, descending = false) {
335
318
  const mod = descending ? -1 : 1;
@@ -398,16 +381,6 @@ class LocalTime {
398
381
  return t1 < t2 ? -1 : 1;
399
382
  }
400
383
  components() {
401
- if (this.utcMode) {
402
- return {
403
- year: this.$date.getUTCFullYear(),
404
- month: this.$date.getUTCMonth() + 1,
405
- day: this.$date.getUTCDate(),
406
- hour: this.$date.getUTCHours(),
407
- minute: this.$date.getUTCMinutes(),
408
- second: this.$date.getSeconds(),
409
- };
410
- }
411
384
  return {
412
385
  year: this.$date.getFullYear(),
413
386
  month: this.$date.getMonth() + 1,
@@ -430,7 +403,7 @@ class LocalTime {
430
403
  return this.$date;
431
404
  }
432
405
  clone() {
433
- return new LocalTime(new Date(this.$date), this.utcMode);
406
+ return new LocalTime(new Date(this.$date));
434
407
  }
435
408
  unix() {
436
409
  return Math.floor(this.$date.valueOf() / 1000);
@@ -442,9 +415,6 @@ class LocalTime {
442
415
  return Math.floor(this.$date.valueOf() / 1000);
443
416
  }
444
417
  toLocalDate() {
445
- if (this.utcMode) {
446
- return localDate_1.LocalDate.create(this.$date.getUTCFullYear(), this.$date.getUTCMonth() + 1, this.$date.getUTCDate());
447
- }
448
418
  return localDate_1.LocalDate.create(this.$date.getFullYear(), this.$date.getMonth() + 1, this.$date.getDate());
449
419
  }
450
420
  toPretty(seconds = true) {
@@ -22,9 +22,8 @@ const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7]);
22
22
  * @experimental
23
23
  */
24
24
  export class LocalTime {
25
- constructor($date, utcMode) {
25
+ constructor($date) {
26
26
  this.$date = $date;
27
- this.utcMode = utcMode;
28
27
  }
29
28
  /**
30
29
  * Parses input String into LocalDate.
@@ -37,14 +36,6 @@ export class LocalTime {
37
36
  }
38
37
  return t;
39
38
  }
40
- utc() {
41
- this.utcMode = true;
42
- return this;
43
- }
44
- local() {
45
- this.utcMode = false;
46
- return this;
47
- }
48
39
  /**
49
40
  * Returns null if invalid
50
41
  */
@@ -71,7 +62,7 @@ export class LocalTime {
71
62
  // if (utc) {
72
63
  // date.setMinutes(date.getMinutes() + date.getTimezoneOffset())
73
64
  // }
74
- return new LocalTime(date, false);
65
+ return new LocalTime(date);
75
66
  }
76
67
  static parseToDate(d) {
77
68
  if (d instanceof LocalTime)
@@ -99,58 +90,56 @@ export class LocalTime {
99
90
  return this.parseOrNull(d) !== null;
100
91
  }
101
92
  static now() {
102
- return new LocalTime(new Date(), false);
93
+ return new LocalTime(new Date());
103
94
  }
104
95
  static fromComponents(c) {
105
- return new LocalTime(new Date(c.year, c.month - 1, c.day, c.hour, c.minute, c.second), false);
96
+ return new LocalTime(new Date(c.year, c.month - 1, c.day, c.hour, c.minute, c.second));
106
97
  }
107
98
  get(unit) {
108
99
  if (unit === 'year') {
109
- return this.utcMode ? this.$date.getUTCFullYear() : this.$date.getFullYear();
100
+ return this.$date.getFullYear();
110
101
  }
111
102
  if (unit === 'month') {
112
- return (this.utcMode ? this.$date.getUTCMonth() : this.$date.getMonth()) + 1;
103
+ return this.$date.getMonth() + 1;
113
104
  }
114
105
  if (unit === 'day') {
115
- return this.utcMode ? this.$date.getUTCDate() : this.$date.getDate();
106
+ return this.$date.getDate();
116
107
  }
117
108
  if (unit === 'hour') {
118
- return this.utcMode ? this.$date.getUTCHours() : this.$date.getHours();
109
+ return this.$date.getHours();
119
110
  }
120
111
  if (unit === 'minute') {
121
- return this.utcMode ? this.$date.getUTCMinutes() : this.$date.getMinutes();
112
+ return this.$date.getMinutes();
122
113
  }
123
114
  if (unit === 'week') {
124
115
  return getWeek(this.$date);
125
116
  }
126
117
  // second
127
- return this.utcMode ? this.$date.getUTCSeconds() : this.$date.getSeconds();
118
+ return this.$date.getSeconds();
128
119
  }
129
120
  set(unit, v, mutate = false) {
130
121
  const t = mutate ? this : this.clone();
131
- /* eslint-disable @typescript-eslint/no-unused-expressions */
132
122
  if (unit === 'year') {
133
- this.utcMode ? t.$date.setUTCFullYear(v) : t.$date.setFullYear(v);
123
+ t.$date.setFullYear(v);
134
124
  }
135
125
  else if (unit === 'month') {
136
- this.utcMode ? t.$date.setUTCMonth(v - 1) : t.$date.setMonth(v - 1);
126
+ t.$date.setMonth(v - 1);
137
127
  }
138
128
  else if (unit === 'day') {
139
- this.utcMode ? t.$date.setUTCDate(v) : t.$date.setDate(v);
129
+ t.$date.setDate(v);
140
130
  }
141
131
  else if (unit === 'hour') {
142
- this.utcMode ? t.$date.setUTCHours(v) : t.$date.setHours(v);
132
+ t.$date.setHours(v);
143
133
  }
144
134
  else if (unit === 'minute') {
145
- this.utcMode ? t.$date.setUTCMinutes(v) : t.$date.setMinutes(v);
135
+ t.$date.setMinutes(v);
146
136
  }
147
137
  else if (unit === 'second') {
148
- this.utcMode ? t.$date.setUTCSeconds(v) : t.$date.setSeconds(v);
138
+ t.$date.setSeconds(v);
149
139
  }
150
140
  else if (unit === 'week') {
151
141
  setWeek(t.$date, v, true);
152
142
  }
153
- /* eslint-enable @typescript-eslint/no-unused-expressions */
154
143
  return t;
155
144
  }
156
145
  year(v) {
@@ -185,27 +174,25 @@ export class LocalTime {
185
174
  }
186
175
  setComponents(c, mutate = false) {
187
176
  const d = mutate ? this.$date : new Date(this.$date);
188
- /* eslint-disable @typescript-eslint/no-unused-expressions */
189
177
  if (c.year) {
190
- this.utcMode ? d.setUTCFullYear(c.year) : d.setFullYear(c.year);
178
+ d.setFullYear(c.year);
191
179
  }
192
180
  if (c.month) {
193
- this.utcMode ? d.setUTCMonth(c.month - 1) : d.setMonth(c.month - 1);
181
+ d.setMonth(c.month - 1);
194
182
  }
195
183
  if (c.day) {
196
- this.utcMode ? d.setUTCDate(c.day) : d.setDate(c.day);
184
+ d.setDate(c.day);
197
185
  }
198
186
  if (c.hour !== undefined) {
199
- this.utcMode ? d.setUTCHours(c.hour) : d.setHours(c.hour);
187
+ d.setHours(c.hour);
200
188
  }
201
189
  if (c.minute !== undefined) {
202
- this.utcMode ? d.setUTCMinutes(c.minute) : d.setMinutes(c.minute);
190
+ d.setMinutes(c.minute);
203
191
  }
204
192
  if (c.second !== undefined) {
205
- this.utcMode ? d.setUTCSeconds(c.second) : d.setSeconds(c.second);
193
+ d.setSeconds(c.second);
206
194
  }
207
- /* eslint-enable @typescript-eslint/no-unused-expressions */
208
- return mutate ? this : new LocalTime(d, this.utcMode);
195
+ return mutate ? this : new LocalTime(d);
209
196
  }
210
197
  add(num, unit, mutate = false) {
211
198
  if (unit === 'week') {
@@ -275,19 +262,18 @@ export class LocalTime {
275
262
  return this;
276
263
  const d = mutate ? this.$date : new Date(this.$date);
277
264
  d.setSeconds(0, 0);
278
- /* eslint-disable @typescript-eslint/no-unused-expressions */
279
265
  if (unit !== 'minute') {
280
- this.utcMode ? d.setUTCMinutes(0) : d.setMinutes(0);
266
+ d.setMinutes(0);
281
267
  if (unit !== 'hour') {
282
- this.utcMode ? d.setUTCHours(0) : d.setHours(0);
268
+ d.setHours(0);
283
269
  if (unit !== 'day') {
284
270
  // year, month or week
285
271
  if (unit === 'year') {
286
- this.utcMode ? d.setUTCMonth(0) : d.setMonth(0);
287
- this.utcMode ? d.setUTCDate(1) : d.setDate(1);
272
+ d.setMonth(0);
273
+ d.setDate(1);
288
274
  }
289
275
  else if (unit === 'month') {
290
- this.utcMode ? d.setUTCDate(1) : d.setDate(1);
276
+ d.setDate(1);
291
277
  }
292
278
  else {
293
279
  // week
@@ -296,23 +282,21 @@ export class LocalTime {
296
282
  }
297
283
  }
298
284
  }
299
- /* eslint-enable @typescript-eslint/no-unused-expressions */
300
- return mutate ? this : new LocalTime(d, this.utcMode);
285
+ return mutate ? this : new LocalTime(d);
301
286
  }
302
287
  endOf(unit, mutate = false) {
303
288
  if (unit === 'second')
304
289
  return this;
305
290
  const d = mutate ? this.$date : new Date(this.$date);
306
291
  d.setSeconds(59, 0);
307
- /* eslint-disable @typescript-eslint/no-unused-expressions */
308
292
  if (unit !== 'minute') {
309
- this.utcMode ? d.setUTCMinutes(59) : d.setMinutes(59);
293
+ d.setMinutes(59);
310
294
  if (unit !== 'hour') {
311
- this.utcMode ? d.setUTCHours(23) : d.setHours(23);
295
+ d.setHours(23);
312
296
  if (unit !== 'day') {
313
297
  // year, month or week
314
298
  if (unit === 'year') {
315
- this.utcMode ? d.setUTCMonth(11) : d.setMonth(11);
299
+ d.setMonth(11);
316
300
  }
317
301
  if (unit === 'week') {
318
302
  endOfWeek(d, true);
@@ -320,13 +304,12 @@ export class LocalTime {
320
304
  else {
321
305
  // year or month
322
306
  const lastDay = LocalDate.getMonthLength(d.getFullYear(), d.getMonth() + 1);
323
- this.utcMode ? d.setUTCDate(lastDay) : d.setDate(lastDay);
307
+ d.setDate(lastDay);
324
308
  }
325
309
  }
326
310
  }
327
311
  }
328
- /* eslint-enable @typescript-eslint/no-unused-expressions */
329
- return mutate ? this : new LocalTime(d, this.utcMode);
312
+ return mutate ? this : new LocalTime(d);
330
313
  }
331
314
  static sort(items, mutate = false, descending = false) {
332
315
  const mod = descending ? -1 : 1;
@@ -395,16 +378,6 @@ export class LocalTime {
395
378
  return t1 < t2 ? -1 : 1;
396
379
  }
397
380
  components() {
398
- if (this.utcMode) {
399
- return {
400
- year: this.$date.getUTCFullYear(),
401
- month: this.$date.getUTCMonth() + 1,
402
- day: this.$date.getUTCDate(),
403
- hour: this.$date.getUTCHours(),
404
- minute: this.$date.getUTCMinutes(),
405
- second: this.$date.getSeconds(),
406
- };
407
- }
408
381
  return {
409
382
  year: this.$date.getFullYear(),
410
383
  month: this.$date.getMonth() + 1,
@@ -427,7 +400,7 @@ export class LocalTime {
427
400
  return this.$date;
428
401
  }
429
402
  clone() {
430
- return new LocalTime(new Date(this.$date), this.utcMode);
403
+ return new LocalTime(new Date(this.$date));
431
404
  }
432
405
  unix() {
433
406
  return Math.floor(this.$date.valueOf() / 1000);
@@ -439,9 +412,6 @@ export class LocalTime {
439
412
  return Math.floor(this.$date.valueOf() / 1000);
440
413
  }
441
414
  toLocalDate() {
442
- if (this.utcMode) {
443
- return LocalDate.create(this.$date.getUTCFullYear(), this.$date.getUTCMonth() + 1, this.$date.getUTCDate());
444
- }
445
415
  return LocalDate.create(this.$date.getFullYear(), this.$date.getMonth() + 1, this.$date.getDate());
446
416
  }
447
417
  toPretty(seconds = true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.99.1",
3
+ "version": "14.99.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -40,7 +40,7 @@ const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7])
40
40
  * @experimental
41
41
  */
42
42
  export class LocalTime {
43
- private constructor(private $date: Date, public utcMode: boolean) {}
43
+ private constructor(private $date: Date) {}
44
44
 
45
45
  /**
46
46
  * Parses input String into LocalDate.
@@ -56,16 +56,6 @@ export class LocalTime {
56
56
  return t
57
57
  }
58
58
 
59
- utc(): this {
60
- this.utcMode = true
61
- return this
62
- }
63
-
64
- local(): this {
65
- this.utcMode = false
66
- return this
67
- }
68
-
69
59
  /**
70
60
  * Returns null if invalid
71
61
  */
@@ -93,7 +83,7 @@ export class LocalTime {
93
83
  // date.setMinutes(date.getMinutes() + date.getTimezoneOffset())
94
84
  // }
95
85
 
96
- return new LocalTime(date, false)
86
+ return new LocalTime(date)
97
87
  }
98
88
 
99
89
  static parseToDate(d: LocalTimeConfig): Date {
@@ -127,58 +117,56 @@ export class LocalTime {
127
117
  }
128
118
 
129
119
  static now(): LocalTime {
130
- return new LocalTime(new Date(), false)
120
+ return new LocalTime(new Date())
131
121
  }
132
122
 
133
123
  static fromComponents(
134
124
  c: { year: number; month: number } & Partial<LocalTimeComponents>,
135
125
  ): LocalTime {
136
- return new LocalTime(new Date(c.year, c.month - 1, c.day, c.hour, c.minute, c.second), false)
126
+ return new LocalTime(new Date(c.year, c.month - 1, c.day, c.hour, c.minute, c.second))
137
127
  }
138
128
 
139
129
  get(unit: LocalTimeUnit): number {
140
130
  if (unit === 'year') {
141
- return this.utcMode ? this.$date.getUTCFullYear() : this.$date.getFullYear()
131
+ return this.$date.getFullYear()
142
132
  }
143
133
  if (unit === 'month') {
144
- return (this.utcMode ? this.$date.getUTCMonth() : this.$date.getMonth()) + 1
134
+ return this.$date.getMonth() + 1
145
135
  }
146
136
  if (unit === 'day') {
147
- return this.utcMode ? this.$date.getUTCDate() : this.$date.getDate()
137
+ return this.$date.getDate()
148
138
  }
149
139
  if (unit === 'hour') {
150
- return this.utcMode ? this.$date.getUTCHours() : this.$date.getHours()
140
+ return this.$date.getHours()
151
141
  }
152
142
  if (unit === 'minute') {
153
- return this.utcMode ? this.$date.getUTCMinutes() : this.$date.getMinutes()
143
+ return this.$date.getMinutes()
154
144
  }
155
145
  if (unit === 'week') {
156
146
  return getWeek(this.$date)
157
147
  }
158
148
  // second
159
- return this.utcMode ? this.$date.getUTCSeconds() : this.$date.getSeconds()
149
+ return this.$date.getSeconds()
160
150
  }
161
151
 
162
152
  set(unit: LocalTimeUnit, v: number, mutate = false): LocalTime {
163
153
  const t = mutate ? this : this.clone()
164
154
 
165
- /* eslint-disable @typescript-eslint/no-unused-expressions */
166
155
  if (unit === 'year') {
167
- this.utcMode ? t.$date.setUTCFullYear(v) : t.$date.setFullYear(v)
156
+ t.$date.setFullYear(v)
168
157
  } else if (unit === 'month') {
169
- this.utcMode ? t.$date.setUTCMonth(v - 1) : t.$date.setMonth(v - 1)
158
+ t.$date.setMonth(v - 1)
170
159
  } else if (unit === 'day') {
171
- this.utcMode ? t.$date.setUTCDate(v) : t.$date.setDate(v)
160
+ t.$date.setDate(v)
172
161
  } else if (unit === 'hour') {
173
- this.utcMode ? t.$date.setUTCHours(v) : t.$date.setHours(v)
162
+ t.$date.setHours(v)
174
163
  } else if (unit === 'minute') {
175
- this.utcMode ? t.$date.setUTCMinutes(v) : t.$date.setMinutes(v)
164
+ t.$date.setMinutes(v)
176
165
  } else if (unit === 'second') {
177
- this.utcMode ? t.$date.setUTCSeconds(v) : t.$date.setSeconds(v)
166
+ t.$date.setSeconds(v)
178
167
  } else if (unit === 'week') {
179
168
  setWeek(t.$date, v, true)
180
169
  }
181
- /* eslint-enable @typescript-eslint/no-unused-expressions */
182
170
 
183
171
  return t
184
172
  }
@@ -239,28 +227,26 @@ export class LocalTime {
239
227
  setComponents(c: Partial<LocalTimeComponents>, mutate = false): LocalTime {
240
228
  const d = mutate ? this.$date : new Date(this.$date)
241
229
 
242
- /* eslint-disable @typescript-eslint/no-unused-expressions */
243
230
  if (c.year) {
244
- this.utcMode ? d.setUTCFullYear(c.year) : d.setFullYear(c.year)
231
+ d.setFullYear(c.year)
245
232
  }
246
233
  if (c.month) {
247
- this.utcMode ? d.setUTCMonth(c.month - 1) : d.setMonth(c.month - 1)
234
+ d.setMonth(c.month - 1)
248
235
  }
249
236
  if (c.day) {
250
- this.utcMode ? d.setUTCDate(c.day) : d.setDate(c.day)
237
+ d.setDate(c.day)
251
238
  }
252
239
  if (c.hour !== undefined) {
253
- this.utcMode ? d.setUTCHours(c.hour) : d.setHours(c.hour)
240
+ d.setHours(c.hour)
254
241
  }
255
242
  if (c.minute !== undefined) {
256
- this.utcMode ? d.setUTCMinutes(c.minute) : d.setMinutes(c.minute)
243
+ d.setMinutes(c.minute)
257
244
  }
258
245
  if (c.second !== undefined) {
259
- this.utcMode ? d.setUTCSeconds(c.second) : d.setSeconds(c.second)
246
+ d.setSeconds(c.second)
260
247
  }
261
- /* eslint-enable @typescript-eslint/no-unused-expressions */
262
248
 
263
- return mutate ? this : new LocalTime(d, this.utcMode)
249
+ return mutate ? this : new LocalTime(d)
264
250
  }
265
251
 
266
252
  add(num: number, unit: LocalTimeUnit, mutate = false): LocalTime {
@@ -337,19 +323,18 @@ export class LocalTime {
337
323
  const d = mutate ? this.$date : new Date(this.$date)
338
324
  d.setSeconds(0, 0)
339
325
 
340
- /* eslint-disable @typescript-eslint/no-unused-expressions */
341
326
  if (unit !== 'minute') {
342
- this.utcMode ? d.setUTCMinutes(0) : d.setMinutes(0)
327
+ d.setMinutes(0)
343
328
  if (unit !== 'hour') {
344
- this.utcMode ? d.setUTCHours(0) : d.setHours(0)
329
+ d.setHours(0)
345
330
  if (unit !== 'day') {
346
331
  // year, month or week
347
332
 
348
333
  if (unit === 'year') {
349
- this.utcMode ? d.setUTCMonth(0) : d.setMonth(0)
350
- this.utcMode ? d.setUTCDate(1) : d.setDate(1)
334
+ d.setMonth(0)
335
+ d.setDate(1)
351
336
  } else if (unit === 'month') {
352
- this.utcMode ? d.setUTCDate(1) : d.setDate(1)
337
+ d.setDate(1)
353
338
  } else {
354
339
  // week
355
340
  startOfWeek(d, true)
@@ -357,9 +342,8 @@ export class LocalTime {
357
342
  }
358
343
  }
359
344
  }
360
- /* eslint-enable @typescript-eslint/no-unused-expressions */
361
345
 
362
- return mutate ? this : new LocalTime(d, this.utcMode)
346
+ return mutate ? this : new LocalTime(d)
363
347
  }
364
348
 
365
349
  endOf(unit: LocalTimeUnit, mutate = false): LocalTime {
@@ -367,16 +351,15 @@ export class LocalTime {
367
351
  const d = mutate ? this.$date : new Date(this.$date)
368
352
  d.setSeconds(59, 0)
369
353
 
370
- /* eslint-disable @typescript-eslint/no-unused-expressions */
371
354
  if (unit !== 'minute') {
372
- this.utcMode ? d.setUTCMinutes(59) : d.setMinutes(59)
355
+ d.setMinutes(59)
373
356
  if (unit !== 'hour') {
374
- this.utcMode ? d.setUTCHours(23) : d.setHours(23)
357
+ d.setHours(23)
375
358
  if (unit !== 'day') {
376
359
  // year, month or week
377
360
 
378
361
  if (unit === 'year') {
379
- this.utcMode ? d.setUTCMonth(11) : d.setMonth(11)
362
+ d.setMonth(11)
380
363
  }
381
364
 
382
365
  if (unit === 'week') {
@@ -384,14 +367,13 @@ export class LocalTime {
384
367
  } else {
385
368
  // year or month
386
369
  const lastDay = LocalDate.getMonthLength(d.getFullYear(), d.getMonth() + 1)
387
- this.utcMode ? d.setUTCDate(lastDay) : d.setDate(lastDay)
370
+ d.setDate(lastDay)
388
371
  }
389
372
  }
390
373
  }
391
374
  }
392
- /* eslint-enable @typescript-eslint/no-unused-expressions */
393
375
 
394
- return mutate ? this : new LocalTime(d, this.utcMode)
376
+ return mutate ? this : new LocalTime(d)
395
377
  }
396
378
 
397
379
  static sort(items: LocalTime[], mutate = false, descending = false): LocalTime[] {
@@ -471,17 +453,6 @@ export class LocalTime {
471
453
  }
472
454
 
473
455
  components(): LocalTimeComponents {
474
- if (this.utcMode) {
475
- return {
476
- year: this.$date.getUTCFullYear(),
477
- month: this.$date.getUTCMonth() + 1,
478
- day: this.$date.getUTCDate(),
479
- hour: this.$date.getUTCHours(),
480
- minute: this.$date.getUTCMinutes(),
481
- second: this.$date.getSeconds(),
482
- }
483
- }
484
-
485
456
  return {
486
457
  year: this.$date.getFullYear(),
487
458
  month: this.$date.getMonth() + 1,
@@ -509,7 +480,7 @@ export class LocalTime {
509
480
  }
510
481
 
511
482
  clone(): LocalTime {
512
- return new LocalTime(new Date(this.$date), this.utcMode)
483
+ return new LocalTime(new Date(this.$date))
513
484
  }
514
485
 
515
486
  unix(): UnixTimestampNumber {
@@ -525,14 +496,6 @@ export class LocalTime {
525
496
  }
526
497
 
527
498
  toLocalDate(): LocalDate {
528
- if (this.utcMode) {
529
- return LocalDate.create(
530
- this.$date.getUTCFullYear(),
531
- this.$date.getUTCMonth() + 1,
532
- this.$date.getUTCDate(),
533
- )
534
- }
535
-
536
499
  return LocalDate.create(
537
500
  this.$date.getFullYear(),
538
501
  this.$date.getMonth() + 1,