swcombine.js 0.0.7 → 0.0.9

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/index.cjs.js CHANGED
@@ -173,7 +173,7 @@ const _SwcTimestamp = class _SwcTimestamp {
173
173
  const seconds = Math.floor(msSinceSwcStart / 1e3);
174
174
  return new _SwcTimestamp({
175
175
  year,
176
- day,
176
+ day: day + 1,
177
177
  hour,
178
178
  minute,
179
179
  second: seconds
@@ -253,6 +253,34 @@ const _SwcTimestamp = class _SwcTimestamp {
253
253
  const endTime = otherTimestamp.toUnixTimestamp("sec");
254
254
  return secondsToDuration(endTime - startTime);
255
255
  }
256
+ /**
257
+ * Convert the SWC timestamp to a string (i.e. Year 25 Day 60, 12:45:21)
258
+ * The following formats are available:
259
+ *
260
+ * 'full': Year 25 Day 60, 6:03:12<br>
261
+ * 'minute': Year 25 Day 60, 6:03<br>
262
+ * 'day': Year 25 Day 60<br>
263
+ * 'shortFull': Y25 D60, 6:03:12<br>
264
+ * 'shortMinute': Y25 D60, 6:03<br>
265
+ * 'shortDay': Y26 D60
266
+ * @param format format to use
267
+ */
268
+ toString(format) {
269
+ switch (format) {
270
+ case "full":
271
+ return `Year ${this.year} Day ${this.day}, ${this.hour}:${this.minute.toString().padStart(2, "0")}:${this.second.toString().padStart(2, "0")}`;
272
+ case "minute":
273
+ return `Year ${this.year} Day ${this.day}, ${this.hour}:${this.minute.toString().padStart(2, "0")}`;
274
+ case "day":
275
+ return `Year ${this.year} Day ${this.day}`;
276
+ case "shortFull":
277
+ return `Y${this.year} D${this.day}, ${this.hour}:${this.minute.toString().padStart(2, "0")}:${this.second.toString().padStart(2, "0")}`;
278
+ case "shortMinute":
279
+ return `Y${this.year} D${this.day}, ${this.hour}:${this.minute.toString().padStart(2, "0")}}`;
280
+ case "shortDay":
281
+ return `Y${this.year} D${this.day}`;
282
+ }
283
+ }
256
284
  /**
257
285
  * @returns {number}
258
286
  * @private
@@ -265,13 +293,13 @@ const _SwcTimestamp = class _SwcTimestamp {
265
293
  let msSinceSwcStart = 0;
266
294
  msSinceSwcStart += this.year * msPerYear;
267
295
  msSinceSwcStart += (this.day - 1) * msPerDay;
268
- msSinceSwcStart += (this.hour + 1) * msPerHour;
296
+ msSinceSwcStart += this.hour * msPerHour;
269
297
  msSinceSwcStart += this.minute * msPerMinute;
270
298
  msSinceSwcStart += this.second * 1e3;
271
299
  return msSinceSwcStart;
272
300
  }
273
301
  };
274
- __publicField(_SwcTimestamp, "swcStart", new Date(1998, 11, 3, 7, 0, 0));
302
+ __publicField(_SwcTimestamp, "swcStart", new Date(Date.UTC(1998, 11, 3, 7, 0, 0)));
275
303
  let SwcTimestamp = _SwcTimestamp;
276
304
  const durationToSeconds = (duration) => (duration.years || 0) * 365 * 24 * 60 * 60 + (duration.days || 0) * 24 * 60 * 60 + (duration.hours || 0) * 60 * 60 + (duration.minutes || 0) * 60 + (duration.seconds || 0);
277
305
  const secondsToDuration = (seconds) => {
package/dist/index.d.ts CHANGED
@@ -440,6 +440,19 @@ export declare class SwcTimestamp {
440
440
  */
441
441
  subtract(duration: Partial<Duration>): SwcTimestamp;
442
442
  getDurationTo(otherTimestamp: SwcTimestamp): Duration;
443
+ /**
444
+ * Convert the SWC timestamp to a string (i.e. Year 25 Day 60, 12:45:21)
445
+ * The following formats are available:
446
+ *
447
+ * 'full': Year 25 Day 60, 6:03:12<br>
448
+ * 'minute': Year 25 Day 60, 6:03<br>
449
+ * 'day': Year 25 Day 60<br>
450
+ * 'shortFull': Y25 D60, 6:03:12<br>
451
+ * 'shortMinute': Y25 D60, 6:03<br>
452
+ * 'shortDay': Y26 D60
453
+ * @param format format to use
454
+ */
455
+ toString(format: 'full' | 'minute' | 'day' | 'shortFull' | 'shortMinute' | 'shortDay'): string;
443
456
  /**
444
457
  * @returns {number}
445
458
  * @private
package/dist/index.esm.js CHANGED
@@ -171,7 +171,7 @@ const _SwcTimestamp = class _SwcTimestamp {
171
171
  const seconds = Math.floor(msSinceSwcStart / 1e3);
172
172
  return new _SwcTimestamp({
173
173
  year,
174
- day,
174
+ day: day + 1,
175
175
  hour,
176
176
  minute,
177
177
  second: seconds
@@ -251,6 +251,34 @@ const _SwcTimestamp = class _SwcTimestamp {
251
251
  const endTime = otherTimestamp.toUnixTimestamp("sec");
252
252
  return secondsToDuration(endTime - startTime);
253
253
  }
254
+ /**
255
+ * Convert the SWC timestamp to a string (i.e. Year 25 Day 60, 12:45:21)
256
+ * The following formats are available:
257
+ *
258
+ * 'full': Year 25 Day 60, 6:03:12<br>
259
+ * 'minute': Year 25 Day 60, 6:03<br>
260
+ * 'day': Year 25 Day 60<br>
261
+ * 'shortFull': Y25 D60, 6:03:12<br>
262
+ * 'shortMinute': Y25 D60, 6:03<br>
263
+ * 'shortDay': Y26 D60
264
+ * @param format format to use
265
+ */
266
+ toString(format) {
267
+ switch (format) {
268
+ case "full":
269
+ return `Year ${this.year} Day ${this.day}, ${this.hour}:${this.minute.toString().padStart(2, "0")}:${this.second.toString().padStart(2, "0")}`;
270
+ case "minute":
271
+ return `Year ${this.year} Day ${this.day}, ${this.hour}:${this.minute.toString().padStart(2, "0")}`;
272
+ case "day":
273
+ return `Year ${this.year} Day ${this.day}`;
274
+ case "shortFull":
275
+ return `Y${this.year} D${this.day}, ${this.hour}:${this.minute.toString().padStart(2, "0")}:${this.second.toString().padStart(2, "0")}`;
276
+ case "shortMinute":
277
+ return `Y${this.year} D${this.day}, ${this.hour}:${this.minute.toString().padStart(2, "0")}}`;
278
+ case "shortDay":
279
+ return `Y${this.year} D${this.day}`;
280
+ }
281
+ }
254
282
  /**
255
283
  * @returns {number}
256
284
  * @private
@@ -263,13 +291,13 @@ const _SwcTimestamp = class _SwcTimestamp {
263
291
  let msSinceSwcStart = 0;
264
292
  msSinceSwcStart += this.year * msPerYear;
265
293
  msSinceSwcStart += (this.day - 1) * msPerDay;
266
- msSinceSwcStart += (this.hour + 1) * msPerHour;
294
+ msSinceSwcStart += this.hour * msPerHour;
267
295
  msSinceSwcStart += this.minute * msPerMinute;
268
296
  msSinceSwcStart += this.second * 1e3;
269
297
  return msSinceSwcStart;
270
298
  }
271
299
  };
272
- __publicField(_SwcTimestamp, "swcStart", new Date(1998, 11, 3, 7, 0, 0));
300
+ __publicField(_SwcTimestamp, "swcStart", new Date(Date.UTC(1998, 11, 3, 7, 0, 0)));
273
301
  let SwcTimestamp = _SwcTimestamp;
274
302
  const durationToSeconds = (duration) => (duration.years || 0) * 365 * 24 * 60 * 60 + (duration.days || 0) * 24 * 60 * 60 + (duration.hours || 0) * 60 * 60 + (duration.minutes || 0) * 60 + (duration.seconds || 0);
275
303
  const secondsToDuration = (seconds) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swcombine.js",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "swcombine",