@naturalcycles/js-lib 14.96.1 → 14.98.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.
@@ -1,20 +1,22 @@
1
1
  import { _assert } from '../error/assert'
2
- import { Sequence } from '../seq/seq'
3
- import { END, IsoDate, UnixTimestamp } from '../types'
2
+ import { IsoDateString, UnixTimestampNumber } from '../types'
4
3
  import { LocalTime } from './localTime'
5
4
 
6
5
  export type LocalDateUnit = 'year' | 'month' | 'day'
7
6
  export type Inclusiveness = '()' | '[]' | '[)' | '(]'
8
7
 
9
- const m31 = new Set<number>([1, 3, 5, 7, 8, 10, 12])
8
+ const MDAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
9
+ const DATE_REGEX = /^(\d\d\d\d)-(\d\d)-(\d\d)$/
10
10
 
11
- export type LocalDateConfig = LocalDate | string
11
+ export type LocalDateConfig = LocalDate | IsoDateString
12
+
13
+ /* eslint-disable no-dupe-class-members */
12
14
 
13
15
  /**
14
16
  * @experimental
15
17
  */
16
18
  export class LocalDate {
17
- private constructor(public year: number, public month: number, public day: number) {}
19
+ private constructor(private $year: number, private $month: number, private $day: number) {}
18
20
 
19
21
  static create(year: number, month: number, day: number): LocalDate {
20
22
  return new LocalDate(year, month, day)
@@ -59,8 +61,13 @@ export class LocalDate {
59
61
  if (!d) return null
60
62
  if (d instanceof LocalDate) return d
61
63
 
62
- // todo: explore more performant options
63
- const [year, month, day] = d.slice(0, 10).split('-').map(Number)
64
+ // const [year, month, day] = d.slice(0, 10).split('-').map(Number)
65
+ const matches = DATE_REGEX.exec(d.slice(0, 10))
66
+ if (!matches) return null
67
+
68
+ const year = Number(matches[1])
69
+ const month = Number(matches[2])
70
+ const day = Number(matches[3])
64
71
 
65
72
  if (
66
73
  !year ||
@@ -77,6 +84,11 @@ export class LocalDate {
77
84
  return new LocalDate(year, month, day)
78
85
  }
79
86
 
87
+ // Can use just .toString()
88
+ // static parseToString(d: LocalDateConfig): IsoDateString {
89
+ // return typeof d === 'string' ? d : d.toString()
90
+ // }
91
+
80
92
  static isValid(iso: string | undefined | null): boolean {
81
93
  return this.parseOrNull(iso) !== null
82
94
  }
@@ -115,81 +127,83 @@ export class LocalDate {
115
127
  }
116
128
 
117
129
  static range(
118
- minIncl: LocalDateConfig,
119
- maxExcl: LocalDateConfig,
130
+ min: LocalDateConfig,
131
+ max: LocalDateConfig,
132
+ incl: Inclusiveness = '[)',
120
133
  step = 1,
121
134
  stepUnit: LocalDateUnit = 'day',
122
135
  ): LocalDate[] {
123
- const days: LocalDate[] = []
124
- let current = LocalDate.of(minIncl).startOf(stepUnit)
125
- const max = LocalDate.of(maxExcl).startOf(stepUnit)
136
+ const dates: LocalDate[] = []
137
+ const $min = LocalDate.of(min)
138
+ const $max = LocalDate.of(max).startOf(stepUnit)
139
+
140
+ let current = $min.startOf(stepUnit)
141
+ if (current.isAfter($min, incl[0] === '[')) {
142
+ // ok
143
+ } else {
144
+ current.add(1, stepUnit, true)
145
+ }
126
146
 
127
- do {
128
- days.push(current)
147
+ const incl2 = incl[1] === ']'
148
+ while (current.isBefore($max, incl2)) {
149
+ dates.push(current)
129
150
  current = current.add(step, stepUnit)
130
- } while (current.isBefore(max))
151
+ }
131
152
 
132
- return days
153
+ return dates
133
154
  }
134
155
 
135
- static rangeSeq(
136
- minIncl: LocalDateConfig,
137
- maxExcl: LocalDateConfig,
138
- step = 1,
139
- stepUnit: LocalDateUnit = 'day',
140
- ): Sequence<LocalDate> {
141
- const min = LocalDate.of(minIncl).startOf(stepUnit)
142
- const max = LocalDate.of(maxExcl).startOf(stepUnit)
143
- return Sequence.create(min, d => {
144
- const next = d.add(step, stepUnit)
145
- return next.isAfter(max) ? END : next
146
- })
147
- }
148
-
149
- static rangeString(
150
- minIncl: LocalDateConfig,
151
- maxExcl: LocalDateConfig,
152
- step = 1,
153
- stepUnit: LocalDateUnit = 'day',
154
- ): IsoDate[] {
155
- return LocalDate.range(minIncl, maxExcl, step, stepUnit).map(ld => ld.toString())
156
+ get(unit: LocalDateUnit): number {
157
+ return unit === 'year' ? this.$year : unit === 'month' ? this.$month : this.$day
156
158
  }
157
159
 
158
- static rangeIncl(
159
- minIncl: LocalDateConfig,
160
- maxIncl: LocalDateConfig,
161
- step = 1,
162
- stepUnit: LocalDateUnit = 'day',
163
- ): LocalDate[] {
164
- return LocalDate.range(minIncl, LocalDate.of(maxIncl).add(1, stepUnit), step, stepUnit)
160
+ set(unit: LocalDateUnit, v: number, mutate = false): LocalDate {
161
+ const t = mutate ? this : this.clone()
162
+
163
+ if (unit === 'year') {
164
+ t.$year = v
165
+ } else if (unit === 'month') {
166
+ t.$month = v
167
+ } else {
168
+ t.$day = v
169
+ }
170
+
171
+ return t
165
172
  }
166
173
 
167
- static rangeInclString(
168
- minIncl: LocalDateConfig,
169
- maxIncl: LocalDateConfig,
170
- step = 1,
171
- stepUnit: LocalDateUnit = 'day',
172
- ): IsoDate[] {
173
- return LocalDate.range(minIncl, LocalDate.of(maxIncl).add(1, stepUnit), step, stepUnit).map(
174
- ld => ld.toString(),
175
- )
174
+ year(): number
175
+ year(v: number): LocalDate
176
+ year(v?: number): number | LocalDate {
177
+ return v === undefined ? this.$year : this.set('year', v)
178
+ }
179
+ month(): number
180
+ month(v: number): LocalDate
181
+ month(v?: number): number | LocalDate {
182
+ return v === undefined ? this.$month : this.set('month', v)
183
+ }
184
+ day(): number
185
+ day(v: number): LocalDate
186
+ day(v?: number): number | LocalDate {
187
+ return v === undefined ? this.$day : this.set('day', v)
176
188
  }
177
189
 
178
190
  isSame(d: LocalDateConfig): boolean {
179
191
  d = LocalDate.of(d)
180
- return this.day === d.day && this.month === d.month && this.year === d.year
192
+ return this.$day === d.$day && this.$month === d.$month && this.$year === d.$year
181
193
  }
182
194
 
183
- isBefore(d: LocalDateConfig): boolean {
184
- return this.cmp(d) === -1
195
+ isBefore(d: LocalDateConfig, inclusive = false): boolean {
196
+ const r = this.cmp(d)
197
+ return r === -1 || (r === 0 && inclusive)
185
198
  }
186
199
 
187
200
  isSameOrBefore(d: LocalDateConfig): boolean {
188
201
  return this.cmp(d) <= 0
189
202
  }
190
203
 
191
- isAfter(d: LocalDateConfig): boolean {
192
- return this.cmp(d) === 1
204
+ isAfter(d: LocalDateConfig, inclusive = false): boolean {
205
+ const r = this.cmp(d)
206
+ return r === 1 || (r === 0 && inclusive)
193
207
  }
194
208
 
195
209
  isSameOrAfter(d: LocalDateConfig): boolean {
@@ -211,12 +225,12 @@ export class LocalDate {
211
225
  */
212
226
  cmp(d: LocalDateConfig): -1 | 0 | 1 {
213
227
  d = LocalDate.of(d)
214
- if (this.year < d.year) return -1
215
- if (this.year > d.year) return 1
216
- if (this.month < d.month) return -1
217
- if (this.month > d.month) return 1
218
- if (this.day < d.day) return -1
219
- if (this.day > d.day) return 1
228
+ if (this.$year < d.$year) return -1
229
+ if (this.$year > d.$year) return 1
230
+ if (this.$month < d.$month) return -1
231
+ if (this.$month > d.$month) return 1
232
+ if (this.$day < d.$day) return -1
233
+ if (this.$day > d.$day) return 1
220
234
  return 0
221
235
  }
222
236
 
@@ -236,33 +250,33 @@ export class LocalDate {
236
250
  d = LocalDate.of(d)
237
251
 
238
252
  if (unit === 'year') {
239
- return this.year - d.year
253
+ return this.$year - d.$year
240
254
  }
241
255
 
242
256
  if (unit === 'month') {
243
- return (this.year - d.year) * 12 + (this.month - d.month)
257
+ return (this.$year - d.$year) * 12 + (this.$month - d.$month)
244
258
  }
245
259
 
246
260
  // unit is 'day'
247
- let days = this.day - d.day
261
+ let days = this.$day - d.$day
248
262
 
249
- if (d.year < this.year) {
250
- for (let year = d.year; year < this.year; year++) {
263
+ if (d.$year < this.$year) {
264
+ for (let year = d.$year; year < this.$year; year++) {
251
265
  days += LocalDate.getYearLength(year)
252
266
  }
253
- } else if (this.year < d.year) {
254
- for (let year = this.year; year < d.year; year++) {
267
+ } else if (this.$year < d.$year) {
268
+ for (let year = this.$year; year < d.$year; year++) {
255
269
  days -= LocalDate.getYearLength(year)
256
270
  }
257
271
  }
258
272
 
259
- if (d.month < this.month) {
260
- for (let month = d.month; month < this.month; month++) {
261
- days += LocalDate.getMonthLength(this.year, month)
273
+ if (d.$month < this.$month) {
274
+ for (let month = d.$month; month < this.$month; month++) {
275
+ days += LocalDate.getMonthLength(this.$year, month)
262
276
  }
263
- } else if (this.month < d.month) {
264
- for (let month = this.month; month < d.month; month++) {
265
- days -= LocalDate.getMonthLength(d.year, month)
277
+ } else if (this.$month < d.$month) {
278
+ for (let month = this.$month; month < d.$month; month++) {
279
+ days -= LocalDate.getMonthLength(d.$year, month)
266
280
  }
267
281
  }
268
282
 
@@ -270,57 +284,62 @@ export class LocalDate {
270
284
  }
271
285
 
272
286
  add(num: number, unit: LocalDateUnit, mutate = false): LocalDate {
273
- let { day, month, year } = this
287
+ let { $day, $month, $year } = this
274
288
 
275
289
  if (unit === 'day') {
276
- day += num
290
+ $day += num
277
291
  } else if (unit === 'month') {
278
- month += num
292
+ $month += num
279
293
  } else if (unit === 'year') {
280
- year += num
294
+ $year += num
281
295
  }
282
296
 
283
297
  // check day overflow
284
- let monLen = LocalDate.getMonthLength(year, month)
285
- while (day > monLen) {
286
- day -= monLen
287
- month += 1
288
- if (month > 12) {
289
- year += 1
290
- month -= 12
291
- }
292
-
293
- monLen = LocalDate.getMonthLength(year, month)
294
- }
295
- while (day < 1) {
296
- day += monLen
297
- month -= 1
298
- if (month < 1) {
299
- year -= 1
300
- month += 12
298
+ if (unit === 'day') {
299
+ if ($day < 1) {
300
+ while ($day < 1) {
301
+ $month -= 1
302
+ if ($month < 1) {
303
+ $year -= 1
304
+ $month += 12
305
+ }
306
+
307
+ $day += LocalDate.getMonthLength($year, $month)
308
+ }
309
+ } else {
310
+ let monLen = LocalDate.getMonthLength($year, $month)
311
+
312
+ while ($day > monLen) {
313
+ $day -= monLen
314
+ $month += 1
315
+ if ($month > 12) {
316
+ $year += 1
317
+ $month -= 12
318
+ }
319
+
320
+ monLen = LocalDate.getMonthLength($year, $month)
321
+ }
301
322
  }
302
-
303
- monLen = LocalDate.getMonthLength(year, month)
304
323
  }
305
324
 
306
325
  // check month overflow
307
- while (month > 12) {
308
- year += 1
309
- month -= 12
326
+ while ($month > 12) {
327
+ $year += 1
328
+ $month -= 12
310
329
  }
311
- while (month < 1) {
312
- year -= 1
313
- month += 12
330
+ while ($month < 1) {
331
+ $year -= 1
332
+ $month += 12
314
333
  }
315
334
 
316
335
  if (mutate) {
317
- this.year = year
318
- this.month = month
319
- this.day = day
336
+ this.$year = $year
337
+ this.$month = $month
338
+ this.$day = $day
320
339
  return this
321
340
  }
322
341
 
323
- return new LocalDate(year, month, day)
342
+ return new LocalDate($year, $month, $day)
324
343
  }
325
344
 
326
345
  subtract(num: number, unit: LocalDateUnit, mutate = false): LocalDate {
@@ -329,21 +348,21 @@ export class LocalDate {
329
348
 
330
349
  startOf(unit: LocalDateUnit): LocalDate {
331
350
  if (unit === 'day') return this
332
- if (unit === 'month') return LocalDate.create(this.year, this.month, 1)
351
+ if (unit === 'month') return LocalDate.create(this.$year, this.$month, 1)
333
352
  // year
334
- return LocalDate.create(this.year, 1, 1)
353
+ return LocalDate.create(this.$year, 1, 1)
335
354
  }
336
355
 
337
356
  endOf(unit: LocalDateUnit): LocalDate {
338
357
  if (unit === 'day') return this
339
358
  if (unit === 'month')
340
359
  return LocalDate.create(
341
- this.year,
342
- this.month,
343
- LocalDate.getMonthLength(this.year, this.month),
360
+ this.$year,
361
+ this.$month,
362
+ LocalDate.getMonthLength(this.$year, this.$month),
344
363
  )
345
364
  // year
346
- return LocalDate.create(this.year, 12, 31)
365
+ return LocalDate.create(this.$year, 12, 31)
347
366
  }
348
367
 
349
368
  static getYearLength(year: number): number {
@@ -352,17 +371,15 @@ export class LocalDate {
352
371
 
353
372
  static getMonthLength(year: number, month: number): number {
354
373
  if (month === 2) return this.isLeapYear(year) ? 29 : 28
355
- return m31.has(month) ? 31 : 30
374
+ return MDAYS[month]!
356
375
  }
357
376
 
358
377
  static isLeapYear(year: number): boolean {
359
- if (year % 4 !== 0) return false
360
- if (year % 100 !== 0) return true
361
- return year % 400 === 0
378
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)
362
379
  }
363
380
 
364
381
  clone(): LocalDate {
365
- return new LocalDate(this.year, this.month, this.day)
382
+ return new LocalDate(this.$year, this.$month, this.$day)
366
383
  }
367
384
 
368
385
  /**
@@ -372,35 +389,35 @@ export class LocalDate {
372
389
  * Timezone will match local timezone.
373
390
  */
374
391
  toDate(): Date {
375
- return new Date(this.year, this.month - 1, this.day)
392
+ return new Date(this.$year, this.$month - 1, this.$day)
376
393
  }
377
394
 
378
395
  toLocalTime(): LocalTime {
379
396
  return LocalTime.of(this.toDate())
380
397
  }
381
398
 
382
- toISODate(): IsoDate {
399
+ toISODate(): IsoDateString {
383
400
  return this.toString()
384
401
  }
385
402
 
386
- toString(): IsoDate {
403
+ toString(): IsoDateString {
387
404
  return [
388
- String(this.year).padStart(4, '0'),
389
- String(this.month).padStart(2, '0'),
390
- String(this.day).padStart(2, '0'),
405
+ String(this.$year).padStart(4, '0'),
406
+ String(this.$month).padStart(2, '0'),
407
+ String(this.$day).padStart(2, '0'),
391
408
  ].join('-')
392
409
  }
393
410
 
394
411
  toStringCompact(): string {
395
412
  return [
396
- String(this.year).padStart(4, '0'),
397
- String(this.month).padStart(2, '0'),
398
- String(this.day).padStart(2, '0'),
413
+ String(this.$year).padStart(4, '0'),
414
+ String(this.$month).padStart(2, '0'),
415
+ String(this.$day).padStart(2, '0'),
399
416
  ].join('')
400
417
  }
401
418
 
402
419
  // May be not optimal, as LocalTime better suits it
403
- unix(): UnixTimestamp {
420
+ unix(): UnixTimestampNumber {
404
421
  return Math.floor(this.toDate().valueOf() / 1000)
405
422
  }
406
423
 
@@ -408,7 +425,7 @@ export class LocalDate {
408
425
  return this.toDate().valueOf()
409
426
  }
410
427
 
411
- toJSON(): IsoDate {
428
+ toJSON(): IsoDateString {
412
429
  return this.toString()
413
430
  }
414
431
  }
@@ -1,11 +1,11 @@
1
1
  import { _assert } from '../error/assert'
2
2
  import { _ms } from '../time/time.util'
3
- import { IsoDate, IsoDateTime, UnixTimestamp } from '../types'
3
+ import { IsoDateString, IsoDateTimeString, UnixTimestampNumber } from '../types'
4
4
  import { Inclusiveness, LocalDate } from './localDate'
5
5
 
6
6
  export type LocalTimeUnit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'
7
7
 
8
- export type LocalTimeConfig = LocalTime | Date | IsoDateTime | UnixTimestamp
8
+ export type LocalTimeConfig = LocalTime | Date | IsoDateTimeString | UnixTimestampNumber
9
9
 
10
10
  export interface LocalTimeComponents {
11
11
  year: number
@@ -62,7 +62,7 @@ export class LocalTime {
62
62
  } else if (typeof d === 'number') {
63
63
  date = new Date(d * 1000)
64
64
  } else {
65
- date = new Date(d)
65
+ date = new Date(d.slice(0, 19))
66
66
  }
67
67
 
68
68
  // validation
@@ -78,6 +78,32 @@ export class LocalTime {
78
78
  return new LocalTime(date, false)
79
79
  }
80
80
 
81
+ static parseToDate(d: LocalTimeConfig): Date {
82
+ if (d instanceof LocalTime) return d.$date
83
+ if (d instanceof Date) return d
84
+
85
+ const date = typeof d === 'number' ? new Date(d * 1000) : new Date(d)
86
+
87
+ if (isNaN(date.getDate())) {
88
+ throw new TypeError(`Cannot parse "${d}" to Date`)
89
+ }
90
+
91
+ return date
92
+ }
93
+
94
+ static parseToUnixTimestamp(d: LocalTimeConfig): UnixTimestampNumber {
95
+ if (typeof d === 'number') return d
96
+ if (d instanceof LocalTime) return d.unix()
97
+
98
+ const date = d instanceof Date ? d : new Date(d)
99
+
100
+ if (isNaN(date.getDate())) {
101
+ throw new TypeError(`Cannot parse "${d}" to UnixTimestamp`)
102
+ }
103
+
104
+ return date.valueOf() / 1000
105
+ }
106
+
81
107
  static isValid(d: LocalTimeConfig | undefined | null): boolean {
82
108
  return this.parseOrNull(d) !== null
83
109
  }
@@ -144,9 +170,9 @@ export class LocalTime {
144
170
  month(v?: number): number | LocalTime {
145
171
  return v === undefined ? this.get('month') : this.set('month', v)
146
172
  }
147
- date(): number
148
- date(v: number): LocalTime
149
- date(v?: number): number | LocalTime {
173
+ day(): number
174
+ day(v: number): LocalTime
175
+ day(v?: number): number | LocalTime {
150
176
  return v === undefined ? this.get('day') : this.set('day', v)
151
177
  }
152
178
  hour(): number
@@ -205,7 +231,7 @@ export class LocalTime {
205
231
  }
206
232
 
207
233
  diff(other: LocalTimeConfig, unit: LocalTimeUnit): number {
208
- const date2 = LocalTime.of(other).$date
234
+ const date2 = LocalTime.parseToDate(other)
209
235
 
210
236
  if (unit === 'year') {
211
237
  return this.$date.getFullYear() - date2.getFullYear()
@@ -295,16 +321,18 @@ export class LocalTime {
295
321
  return this.cmp(d) === 0
296
322
  }
297
323
 
298
- isBefore(d: LocalTimeConfig): boolean {
299
- return this.cmp(d) === -1
324
+ isBefore(d: LocalTimeConfig, inclusive = false): boolean {
325
+ const r = this.cmp(d)
326
+ return r === -1 || (r === 0 && inclusive)
300
327
  }
301
328
 
302
329
  isSameOrBefore(d: LocalTimeConfig): boolean {
303
330
  return this.cmp(d) <= 0
304
331
  }
305
332
 
306
- isAfter(d: LocalTimeConfig): boolean {
307
- return this.cmp(d) === 1
333
+ isAfter(d: LocalTimeConfig, inclusive = false): boolean {
334
+ const r = this.cmp(d)
335
+ return r === 1 || (r === 0 && inclusive)
308
336
  }
309
337
 
310
338
  isSameOrAfter(d: LocalTimeConfig): boolean {
@@ -326,7 +354,7 @@ export class LocalTime {
326
354
  */
327
355
  cmp(d: LocalTimeConfig): -1 | 0 | 1 {
328
356
  const t1 = this.$date.valueOf()
329
- const t2 = LocalTime.of(d).$date.valueOf()
357
+ const t2 = LocalTime.parseToDate(d).valueOf()
330
358
  if (t1 === t2) return 0
331
359
  return t1 < t2 ? -1 : 1
332
360
  }
@@ -355,8 +383,8 @@ export class LocalTime {
355
383
  }
356
384
  }
357
385
 
358
- fromNow(now: LocalTimeConfig = LocalTime.now()): string {
359
- const msDiff = LocalTime.of(now).unixMillis() - this.unixMillis()
386
+ fromNow(now: LocalTimeConfig = new Date()): string {
387
+ const msDiff = LocalTime.parseToDate(now).valueOf() - this.$date.valueOf()
360
388
 
361
389
  if (msDiff === 0) return 'now'
362
390
 
@@ -375,7 +403,7 @@ export class LocalTime {
375
403
  return new LocalTime(new Date(this.$date), this.utcMode)
376
404
  }
377
405
 
378
- unix(): UnixTimestamp {
406
+ unix(): UnixTimestampNumber {
379
407
  return Math.floor(this.$date.valueOf() / 1000)
380
408
  }
381
409
 
@@ -383,7 +411,7 @@ export class LocalTime {
383
411
  return this.$date.valueOf()
384
412
  }
385
413
 
386
- valueOf(): UnixTimestamp {
414
+ valueOf(): UnixTimestampNumber {
387
415
  return Math.floor(this.$date.valueOf() / 1000)
388
416
  }
389
417
 
@@ -403,7 +431,7 @@ export class LocalTime {
403
431
  )
404
432
  }
405
433
 
406
- toPretty(seconds = true): IsoDateTime {
434
+ toPretty(seconds = true): IsoDateTimeString {
407
435
  const { year, month, day, hour, minute, second } = this.components()
408
436
 
409
437
  return (
@@ -432,14 +460,14 @@ export class LocalTime {
432
460
  /**
433
461
  * Returns e.g: `1984-06-21T17:56:21`, only the date part of DateTime
434
462
  */
435
- toISODateTime(): IsoDateTime {
463
+ toISODateTime(): IsoDateTimeString {
436
464
  return this.$date.toISOString().slice(0, 19)
437
465
  }
438
466
 
439
467
  /**
440
468
  * Returns e.g: `1984-06-21`, only the date part of DateTime
441
469
  */
442
- toISODate(): IsoDate {
470
+ toISODate(): IsoDateString {
443
471
  const { year, month, day } = this.components()
444
472
 
445
473
  return [
@@ -488,7 +516,7 @@ export class LocalTime {
488
516
  return String(this.unix())
489
517
  }
490
518
 
491
- toJSON(): UnixTimestamp {
519
+ toJSON(): UnixTimestampNumber {
492
520
  return this.unix()
493
521
  }
494
522
  }
@@ -499,5 +527,3 @@ export class LocalTime {
499
527
  export function localTime(d?: LocalTimeConfig): LocalTime {
500
528
  return d ? LocalTime.of(d) : LocalTime.now()
501
529
  }
502
-
503
- // todo: range