Skip to content

Commit b6ecde8

Browse files
committed
#459461 - Fix time interval policy
1 parent a8ae37f commit b6ecde8

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/app/shared/utils/date-utils.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,34 @@ export function adjustDate(date: Date, operator: OperatorDto): string | null {
55
return null;
66
}
77

8-
if(operator === 'LEQ' || operator === 'LT') {
9-
const adjustedDate = new Date(Date.UTC(
10-
date.getFullYear(),
11-
date.getMonth(),
12-
date.getDate(),
13-
23, 59, 59, 999
14-
));
8+
let adjustedDate: Date;
159

16-
return adjustedDate.toISOString();
17-
} else {
18-
const adjustedDate = new Date(Date.UTC(
19-
date.getFullYear(),
20-
date.getMonth(),
21-
date.getDate(),
22-
0, 0, 0, 0
23-
));
24-
25-
return adjustedDate.toISOString();
10+
switch (operator) {
11+
case 'LT':
12+
case 'GEQ':
13+
adjustedDate = new Date(Date.UTC(
14+
date.getFullYear(),
15+
date.getMonth(),
16+
date.getDate(),
17+
0, 0, 0, 0
18+
));
19+
break;
20+
case 'LEQ':
21+
case 'GT':
22+
adjustedDate = new Date(Date.UTC(
23+
date.getFullYear(),
24+
date.getMonth(),
25+
date.getDate(),
26+
23, 59, 59, 999
27+
));
28+
break;
29+
default:
30+
return null;
2631
}
2732

33+
return adjustedDate.toISOString();
2834
}
35+
2936
export function convertUTCToLocalDate(utcISOString: string): Date {
3037
const utcDate = new Date(utcISOString);
3138

0 commit comments

Comments
 (0)