@naturalcycles/js-lib 14.98.2 → 14.98.3
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/dist/datetime/localDate.d.ts +5 -1
- package/dist/datetime/localDate.js +6 -0
- package/dist/datetime/localTime.d.ts +1 -1
- package/dist/datetime/localTime.js +3 -2
- package/dist-esm/datetime/localDate.js +6 -0
- package/dist-esm/datetime/localTime.js +3 -2
- package/package.json +2 -2
- package/src/datetime/localDate.ts +8 -1
- package/src/datetime/localTime.ts +3 -2
- package/src/promise/pRetry.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IsoDateString, UnixTimestampNumber } from '../types';
|
|
1
|
+
import { IsoDateString, IsoDateTimeString, UnixTimestampNumber } from '../types';
|
|
2
2
|
import { LocalTime } from './localTime';
|
|
3
3
|
export declare type LocalDateUnit = 'year' | 'month' | 'day';
|
|
4
4
|
export declare type Inclusiveness = '()' | '[]' | '[)' | '(]';
|
|
@@ -80,6 +80,10 @@ export declare class LocalDate {
|
|
|
80
80
|
toDate(): Date;
|
|
81
81
|
toLocalTime(): LocalTime;
|
|
82
82
|
toISODate(): IsoDateString;
|
|
83
|
+
/**
|
|
84
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
85
|
+
*/
|
|
86
|
+
toISODateTime(): IsoDateTimeString;
|
|
83
87
|
toString(): IsoDateString;
|
|
84
88
|
toStringCompact(): string;
|
|
85
89
|
unix(): UnixTimestampNumber;
|
|
@@ -334,6 +334,12 @@ class LocalDate {
|
|
|
334
334
|
toISODate() {
|
|
335
335
|
return this.toString();
|
|
336
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
339
|
+
*/
|
|
340
|
+
toISODateTime() {
|
|
341
|
+
return this.toString() + 'T00:00:00';
|
|
342
|
+
}
|
|
337
343
|
toString() {
|
|
338
344
|
return [
|
|
339
345
|
String(this.$year).padStart(4, '0'),
|
|
@@ -83,7 +83,7 @@ export declare class LocalTime {
|
|
|
83
83
|
toLocalDate(): LocalDate;
|
|
84
84
|
toPretty(seconds?: boolean): IsoDateTimeString;
|
|
85
85
|
/**
|
|
86
|
-
* Returns e.g: `1984-06-21T17:56:21
|
|
86
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
87
87
|
*/
|
|
88
88
|
toISODateTime(): IsoDateTimeString;
|
|
89
89
|
/**
|
|
@@ -219,8 +219,9 @@ class LocalTime {
|
|
|
219
219
|
if (unit === 'second')
|
|
220
220
|
return this;
|
|
221
221
|
const d = mutate ? this.$date : new Date(this.$date);
|
|
222
|
+
d.setMilliseconds(0);
|
|
223
|
+
d.setSeconds(0);
|
|
222
224
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
223
|
-
this.utcMode ? d.setUTCSeconds(0) : d.setSeconds(0);
|
|
224
225
|
if (unit !== 'minute') {
|
|
225
226
|
this.utcMode ? d.setUTCMinutes(0) : d.setMinutes(0);
|
|
226
227
|
if (unit !== 'hour') {
|
|
@@ -371,7 +372,7 @@ class LocalTime {
|
|
|
371
372
|
// .join(' ')
|
|
372
373
|
}
|
|
373
374
|
/**
|
|
374
|
-
* Returns e.g: `1984-06-21T17:56:21
|
|
375
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
375
376
|
*/
|
|
376
377
|
toISODateTime() {
|
|
377
378
|
return this.$date.toISOString().slice(0, 19);
|
|
@@ -331,6 +331,12 @@ export class LocalDate {
|
|
|
331
331
|
toISODate() {
|
|
332
332
|
return this.toString();
|
|
333
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
336
|
+
*/
|
|
337
|
+
toISODateTime() {
|
|
338
|
+
return this.toString() + 'T00:00:00';
|
|
339
|
+
}
|
|
334
340
|
toString() {
|
|
335
341
|
return [
|
|
336
342
|
String(this.$year).padStart(4, '0'),
|
|
@@ -216,8 +216,9 @@ export class LocalTime {
|
|
|
216
216
|
if (unit === 'second')
|
|
217
217
|
return this;
|
|
218
218
|
const d = mutate ? this.$date : new Date(this.$date);
|
|
219
|
+
d.setMilliseconds(0);
|
|
220
|
+
d.setSeconds(0);
|
|
219
221
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
220
|
-
this.utcMode ? d.setUTCSeconds(0) : d.setSeconds(0);
|
|
221
222
|
if (unit !== 'minute') {
|
|
222
223
|
this.utcMode ? d.setUTCMinutes(0) : d.setMinutes(0);
|
|
223
224
|
if (unit !== 'hour') {
|
|
@@ -368,7 +369,7 @@ export class LocalTime {
|
|
|
368
369
|
// .join(' ')
|
|
369
370
|
}
|
|
370
371
|
/**
|
|
371
|
-
* Returns e.g: `1984-06-21T17:56:21
|
|
372
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
372
373
|
*/
|
|
373
374
|
toISODateTime() {
|
|
374
375
|
return this.$date.toISOString().slice(0, 19);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
|
-
"version": "14.98.
|
|
3
|
+
"version": "14.98.3",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"build-prod": "build-prod-esm-cjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@naturalcycles/nodejs-lib": "^12.33.4",
|
|
17
17
|
"@naturalcycles/time-lib": "^3.5.1",
|
|
18
18
|
"@types/node": "^17.0.4",
|
|
19
|
-
"jest": "^
|
|
19
|
+
"jest": "^28.0.3",
|
|
20
20
|
"patch-package": "^6.2.1",
|
|
21
21
|
"prettier": "^2.1.2",
|
|
22
22
|
"rxjs": "^7.0.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _assert } from '../error/assert'
|
|
2
|
-
import { IsoDateString, UnixTimestampNumber } from '../types'
|
|
2
|
+
import { IsoDateString, IsoDateTimeString, UnixTimestampNumber } from '../types'
|
|
3
3
|
import { LocalTime } from './localTime'
|
|
4
4
|
|
|
5
5
|
export type LocalDateUnit = 'year' | 'month' | 'day'
|
|
@@ -400,6 +400,13 @@ export class LocalDate {
|
|
|
400
400
|
return this.toString()
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
+
/**
|
|
404
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
405
|
+
*/
|
|
406
|
+
toISODateTime(): IsoDateTimeString {
|
|
407
|
+
return this.toString() + 'T00:00:00'
|
|
408
|
+
}
|
|
409
|
+
|
|
403
410
|
toString(): IsoDateString {
|
|
404
411
|
return [
|
|
405
412
|
String(this.$year).padStart(4, '0'),
|
|
@@ -267,9 +267,10 @@ export class LocalTime {
|
|
|
267
267
|
if (unit === 'second') return this
|
|
268
268
|
|
|
269
269
|
const d = mutate ? this.$date : new Date(this.$date)
|
|
270
|
+
d.setMilliseconds(0)
|
|
271
|
+
d.setSeconds(0)
|
|
270
272
|
|
|
271
273
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
272
|
-
this.utcMode ? d.setUTCSeconds(0) : d.setSeconds(0)
|
|
273
274
|
if (unit !== 'minute') {
|
|
274
275
|
this.utcMode ? d.setUTCMinutes(0) : d.setMinutes(0)
|
|
275
276
|
if (unit !== 'hour') {
|
|
@@ -458,7 +459,7 @@ export class LocalTime {
|
|
|
458
459
|
}
|
|
459
460
|
|
|
460
461
|
/**
|
|
461
|
-
* Returns e.g: `1984-06-21T17:56:21
|
|
462
|
+
* Returns e.g: `1984-06-21T17:56:21`
|
|
462
463
|
*/
|
|
463
464
|
toISODateTime(): IsoDateTimeString {
|
|
464
465
|
return this.$date.toISOString().slice(0, 19)
|
package/src/promise/pRetry.ts
CHANGED
|
@@ -169,7 +169,7 @@ export async function pRetry<T>(
|
|
|
169
169
|
|
|
170
170
|
const r = await fn(attempt)
|
|
171
171
|
|
|
172
|
-
clearTimeout(timer
|
|
172
|
+
clearTimeout(timer)
|
|
173
173
|
|
|
174
174
|
if (logSuccess) {
|
|
175
175
|
logger.log(`${fname} attempt #${attempt} succeeded in ${_since(started)}`)
|
|
@@ -177,7 +177,7 @@ export async function pRetry<T>(
|
|
|
177
177
|
|
|
178
178
|
resolve(r)
|
|
179
179
|
} catch (err) {
|
|
180
|
-
clearTimeout(timer
|
|
180
|
+
clearTimeout(timer)
|
|
181
181
|
|
|
182
182
|
if (logFailures) {
|
|
183
183
|
logger.warn(
|