ismx-nexo-node-app 0.4.9 → 0.4.11
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/js/api/ServiceRestFormalTemplate.js +1 -2
- package/dist/js/business/utils/DateUtils.js +21 -4
- package/dist/types/business/utils/DateUtils.d.ts +4 -1
- package/package.json +1 -1
- package/src/main/node/api/ServiceRestFormalTemplate.ts +1 -2
- package/src/main/node/business/utils/DateUtils.ts +24 -4
|
@@ -97,8 +97,7 @@ class ServiceRestFormalTemplate {
|
|
|
97
97
|
}
|
|
98
98
|
servePost(request) {
|
|
99
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
|
|
101
|
-
return Service_1.HttpResponse.ok(entity);
|
|
100
|
+
return Service_1.HttpResponse.ok(yield this.database.add(this.tableName, request.body));
|
|
102
101
|
});
|
|
103
102
|
}
|
|
104
103
|
servePostList(request) {
|
|
@@ -7,10 +7,27 @@ class DateUtils {
|
|
|
7
7
|
static getDay(date, using = ['Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat']) {
|
|
8
8
|
return using[date.getDay()];
|
|
9
9
|
}
|
|
10
|
-
static
|
|
11
|
-
let
|
|
12
|
-
let
|
|
13
|
-
|
|
10
|
+
static getStartOfWeek(year, week) {
|
|
11
|
+
let date = new Date(year, 0, 1);
|
|
12
|
+
let dayOfWeek = date.getDay(); // 0 is Sunday, 1 is Monday, etc.
|
|
13
|
+
let daysToAdd = (week - 1) * 7 - dayOfWeek + 1; // Start week on Monday
|
|
14
|
+
date.setDate(date.getDate() + daysToAdd);
|
|
15
|
+
return date;
|
|
16
|
+
}
|
|
17
|
+
static getEndOfWeek(year, week) {
|
|
18
|
+
return this.getStartOfWeek(year, week + 1);
|
|
19
|
+
}
|
|
20
|
+
static toIsoTime(date) {
|
|
21
|
+
let hours = date.getHours().toString().padStart(2, "0");
|
|
22
|
+
let minutes = date.getMinutes().toString().padStart(2, "0");
|
|
23
|
+
let seconds = date.getSeconds().toString().padStart(2, "0");
|
|
24
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
25
|
+
}
|
|
26
|
+
static toIsoDate(date) {
|
|
27
|
+
let year = date.getFullYear().toString();
|
|
28
|
+
let month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
29
|
+
let day = date.getDate().toString().padStart(2, "0");
|
|
30
|
+
return `${year}-${month}-${day}`;
|
|
14
31
|
}
|
|
15
32
|
static sum(date, value, component) {
|
|
16
33
|
let year = date.getFullYear();
|
|
@@ -8,6 +8,9 @@ export default abstract class DateUtils {
|
|
|
8
8
|
static readonly YEARS: number;
|
|
9
9
|
static getMonth(date: Date, using?: string[]): string;
|
|
10
10
|
static getDay(date: Date, using?: string[]): string;
|
|
11
|
-
static
|
|
11
|
+
static getStartOfWeek(year: number, week: number): Date;
|
|
12
|
+
static getEndOfWeek(year: number, week: number): Date;
|
|
13
|
+
static toIsoTime(date: Date): string;
|
|
14
|
+
static toIsoDate(date: Date): string;
|
|
12
15
|
static sum(date: Date, value: number, component: number): Date;
|
|
13
16
|
}
|
package/package.json
CHANGED
|
@@ -104,8 +104,7 @@ export default class ServiceRestFormalTemplate<Model=any>
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
protected async servePost(request: HttpRequest<Model>): Promise<HttpResponse<Model>> {
|
|
107
|
-
|
|
108
|
-
return HttpResponse.ok(entity);
|
|
107
|
+
return HttpResponse.ok(await this.database.add<Model>(this.tableName, request.body));
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
protected async servePostList(request: HttpRequest<Model[]>): Promise<HttpResponse<Model[]>> {
|
|
@@ -17,10 +17,30 @@ export default abstract class DateUtils {
|
|
|
17
17
|
return using[date.getDay()]
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
static
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
|
|
20
|
+
static getStartOfWeek(year: number, week: number): Date {
|
|
21
|
+
let date = new Date(year, 0, 1);
|
|
22
|
+
let dayOfWeek = date.getDay(); // 0 is Sunday, 1 is Monday, etc.
|
|
23
|
+
let daysToAdd = (week - 1) * 7 - dayOfWeek + 1; // Start week on Monday
|
|
24
|
+
date.setDate(date.getDate() + daysToAdd);
|
|
25
|
+
return date;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static getEndOfWeek(year: number, week: number) {
|
|
29
|
+
return this.getStartOfWeek(year, week+1)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static toIsoTime(date: Date) {
|
|
33
|
+
let hours = date.getHours().toString().padStart(2, "0");
|
|
34
|
+
let minutes = date.getMinutes().toString().padStart(2, "0");
|
|
35
|
+
let seconds = date.getSeconds().toString().padStart(2, "0");
|
|
36
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static toIsoDate(date: Date) {
|
|
40
|
+
let year = date.getFullYear().toString();
|
|
41
|
+
let month = (date.getMonth()+1).toString().padStart(2, "0");
|
|
42
|
+
let day = date.getDate().toString().padStart(2, "0");
|
|
43
|
+
return `${year}-${month}-${day}`;
|
|
24
44
|
}
|
|
25
45
|
|
|
26
46
|
static sum(date:Date, value:number, component: number) {
|