ismx-nexo-node-app 0.4.15 → 0.4.16

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.
@@ -17,11 +17,18 @@ class DateUtils {
17
17
  static getEndOfWeek(year, week) {
18
18
  return this.getStartOfWeek(year, week + 1);
19
19
  }
20
- static toIsoTime(date) {
20
+ static toIsoTime(date, precision = DateUtils.SECONDS) {
21
21
  let hours = date.getHours().toString().padStart(2, "0");
22
22
  let minutes = date.getMinutes().toString().padStart(2, "0");
23
23
  let seconds = date.getSeconds().toString().padStart(2, "0");
24
- return `${hours}:${minutes}:${seconds}`;
24
+ let result = "";
25
+ if (precision !== DateUtils.HOURS)
26
+ result += hours;
27
+ if (precision !== DateUtils.MINUTES)
28
+ result += `:${minutes}`;
29
+ if (precision !== DateUtils.SECONDS)
30
+ result += `:${seconds}`;
31
+ return result;
25
32
  }
26
33
  static toIsoDate(date) {
27
34
  let year = date.getFullYear().toString();
@@ -10,7 +10,7 @@ export default abstract class DateUtils {
10
10
  static getDay(date: Date, using?: string[]): string;
11
11
  static getStartOfWeek(year: number, week: number): Date;
12
12
  static getEndOfWeek(year: number, week: number): Date;
13
- static toIsoTime(date: Date): string;
13
+ static toIsoTime(date: Date, precision?: number): string;
14
14
  static toIsoDate(date: Date): string;
15
15
  static sum(date: Date, value: number, component: number): Date;
16
16
  static sumTime(date: string, value: number, component: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.15",
3
+ "version": "0.4.16",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -29,11 +29,17 @@ export default abstract class DateUtils {
29
29
  return this.getStartOfWeek(year, week+1)
30
30
  }
31
31
 
32
- static toIsoTime(date: Date) {
32
+ static toIsoTime(date: Date, precision: number = DateUtils.SECONDS) {
33
33
  let hours = date.getHours().toString().padStart(2, "0");
34
34
  let minutes = date.getMinutes().toString().padStart(2, "0");
35
35
  let seconds = date.getSeconds().toString().padStart(2, "0");
36
- return `${hours}:${minutes}:${seconds}`;
36
+
37
+ let result = ""
38
+ if (precision !== DateUtils.HOURS) result += hours;
39
+ if (precision !== DateUtils.MINUTES) result += `:${minutes}`;
40
+ if (precision !== DateUtils.SECONDS) result += `:${seconds}`;
41
+
42
+ return result;
37
43
  }
38
44
 
39
45
  static toIsoDate(date: Date) {