@eliasrrosa/tutorhub-public-assets 0.0.19 → 0.0.20

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.
@@ -31,6 +31,7 @@ export declare class ISO8601Time implements ITime {
31
31
  static getNow(): string;
32
32
  getNowTimeString: typeof ISO8601Time.getNow;
33
33
  getTimezone: () => IISO8601Timezone;
34
+ getTimeInMinutes: () => number;
34
35
  addHours: (hours: number) => ITime;
35
36
  addMinutes: (minutes: number) => ITime;
36
37
  addTimezone: (timezone: string | number) => ITime;
@@ -25,6 +25,11 @@ class ISO8601Time {
25
25
  this.getTimezone = () => {
26
26
  return new ISO8601Timezone_1.ISO8601Timezone(this.originalTimeString);
27
27
  };
28
+ this.getTimeInMinutes = () => {
29
+ const hours = parseInt(this.getHoursString());
30
+ const minutes = parseInt(this.getMinutesString());
31
+ return hours * 60 + minutes;
32
+ };
28
33
  this.addHours = (hours) => {
29
34
  let targetHour = parseInt(this.getHoursString()) + hours;
30
35
  while (targetHour >= 24) {
@@ -50,7 +55,9 @@ class ISO8601Time {
50
55
  .selector.getTimezoneString(timeWithAddedHours.originalTimeString)}`);
51
56
  };
52
57
  this.addTimezone = (timezone) => {
53
- const newTimezone = typeof timezone == "number" ? this.timezoneParser.toString(timezone) : timezone;
58
+ const newTimezone = typeof timezone == "number"
59
+ ? this.timezoneParser.toString(timezone)
60
+ : timezone;
54
61
  return new ISO8601Time(`${this.getHoursString()}:${this.getMinutesString()}:${this.getSecondsString()}${newTimezone}`);
55
62
  };
56
63
  this.originalTimeString = value ? value : this.getNowTimeString();
@@ -211,4 +211,26 @@ describe("ISO8601Time", () => {
211
211
  expect(time.addTimezone("+03:00").getTimezoneString()).toEqual("+03:00");
212
212
  });
213
213
  });
214
+ describe("ISO8601Time.getTimeInMinutes()", () => {
215
+ it("Should return 60 for 01:00", () => {
216
+ const time = new ISO8601Time_1.ISO8601Time("01:00");
217
+ expect(time.getTimeInMinutes()).toEqual(60);
218
+ });
219
+ it("Should return 60 for 01:00:00", () => {
220
+ const time = new ISO8601Time_1.ISO8601Time("01:00:00");
221
+ expect(time.getTimeInMinutes()).toEqual(60);
222
+ });
223
+ it("Should return 60 for 01:00:00+03:00", () => {
224
+ const time = new ISO8601Time_1.ISO8601Time("01:00:00+03:00");
225
+ expect(time.getTimeInMinutes()).toEqual(60);
226
+ });
227
+ it("Should return 60 for 01:00:00Z", () => {
228
+ const time = new ISO8601Time_1.ISO8601Time("01:00:00Z");
229
+ expect(time.getTimeInMinutes()).toEqual(60);
230
+ });
231
+ it("Should return 90 for 01:30", () => {
232
+ const time = new ISO8601Time_1.ISO8601Time("01:30");
233
+ expect(time.getTimeInMinutes()).toEqual(90);
234
+ });
235
+ });
214
236
  });
@@ -30,4 +30,9 @@ export interface ITime {
30
30
  * and `(+|-)HH:MM` for others. */
31
31
  addTimezone: (timezone: string | number) => ITime;
32
32
  getTimezoneString: () => string;
33
+ /**
34
+ * Returns the quantity of minutes based on original time string.
35
+ * Eg:. `01:00 -> 60`, `02:00:00-03:00 -> 120`, `02:30 -> 150`
36
+ */
37
+ getTimeInMinutes: () => number;
33
38
  }
package/dist/index.cjs CHANGED
@@ -443,6 +443,11 @@ var ISO8601Time = class _ISO8601Time {
443
443
  this.getTimezone = () => {
444
444
  return new ISO8601Timezone(this.originalTimeString);
445
445
  };
446
+ this.getTimeInMinutes = () => {
447
+ const hours = parseInt(this.getHoursString());
448
+ const minutes = parseInt(this.getMinutesString());
449
+ return hours * 60 + minutes;
450
+ };
446
451
  this.addHours = (hours) => {
447
452
  let targetHour = parseInt(this.getHoursString()) + hours;
448
453
  while (targetHour >= 24) {
package/dist/index.js CHANGED
@@ -406,6 +406,11 @@ var ISO8601Time = class _ISO8601Time {
406
406
  this.getTimezone = () => {
407
407
  return new ISO8601Timezone(this.originalTimeString);
408
408
  };
409
+ this.getTimeInMinutes = () => {
410
+ const hours = parseInt(this.getHoursString());
411
+ const minutes = parseInt(this.getMinutesString());
412
+ return hours * 60 + minutes;
413
+ };
409
414
  this.addHours = (hours) => {
410
415
  let targetHour = parseInt(this.getHoursString()) + hours;
411
416
  while (targetHour >= 24) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliasrrosa/tutorhub-public-assets",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "Assets, mainly interfaces, to be shared among different Tutorhub apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",