@naturalcycles/js-lib 14.89.0 → 14.90.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.
@@ -69,6 +69,10 @@ export declare class LocalTime {
69
69
  valueOf(): UnixTimestamp;
70
70
  toISO8601(): IsoDateTime;
71
71
  toPretty(): IsoDateTime;
72
+ /**
73
+ * Returns e.g: `19840621_1705`
74
+ */
75
+ toStringCompact(seconds?: boolean): string;
72
76
  toString(): string;
73
77
  toJSON(): UnixTimestamp;
74
78
  }
@@ -286,6 +286,20 @@ class LocalTime {
286
286
  toPretty() {
287
287
  return this.$date.toISOString().slice(0, 19).split('T').join(' ');
288
288
  }
289
+ /**
290
+ * Returns e.g: `19840621_1705`
291
+ */
292
+ toStringCompact(seconds = false) {
293
+ return [
294
+ String(this.$date.getFullYear()).padStart(4, '0'),
295
+ String(this.$date.getMonth() + 1).padStart(2, '0'),
296
+ String(this.$date.getDate()).padStart(2, '0'),
297
+ '_',
298
+ String(this.$date.getHours()).padStart(2, '0'),
299
+ String(this.$date.getMinutes()).padStart(2, '0'),
300
+ seconds ? String(this.$date.getSeconds()).padStart(2, '0') : '',
301
+ ].join('');
302
+ }
289
303
  toString() {
290
304
  return String(this.unix());
291
305
  }
@@ -283,6 +283,20 @@ export class LocalTime {
283
283
  toPretty() {
284
284
  return this.$date.toISOString().slice(0, 19).split('T').join(' ');
285
285
  }
286
+ /**
287
+ * Returns e.g: `19840621_1705`
288
+ */
289
+ toStringCompact(seconds = false) {
290
+ return [
291
+ String(this.$date.getFullYear()).padStart(4, '0'),
292
+ String(this.$date.getMonth() + 1).padStart(2, '0'),
293
+ String(this.$date.getDate()).padStart(2, '0'),
294
+ '_',
295
+ String(this.$date.getHours()).padStart(2, '0'),
296
+ String(this.$date.getMinutes()).padStart(2, '0'),
297
+ seconds ? String(this.$date.getSeconds()).padStart(2, '0') : '',
298
+ ].join('');
299
+ }
286
300
  toString() {
287
301
  return String(this.unix());
288
302
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.89.0",
3
+ "version": "14.90.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -343,6 +343,21 @@ export class LocalTime {
343
343
  return this.$date.toISOString().slice(0, 19).split('T').join(' ')
344
344
  }
345
345
 
346
+ /**
347
+ * Returns e.g: `19840621_1705`
348
+ */
349
+ toStringCompact(seconds = false): string {
350
+ return [
351
+ String(this.$date.getFullYear()).padStart(4, '0'),
352
+ String(this.$date.getMonth() + 1).padStart(2, '0'),
353
+ String(this.$date.getDate()).padStart(2, '0'),
354
+ '_',
355
+ String(this.$date.getHours()).padStart(2, '0'),
356
+ String(this.$date.getMinutes()).padStart(2, '0'),
357
+ seconds ? String(this.$date.getSeconds()).padStart(2, '0') : '',
358
+ ].join('')
359
+ }
360
+
346
361
  toString(): string {
347
362
  return String(this.unix())
348
363
  }