Skip to content

Commit 1c3043e

Browse files
committed
Validate time range
1 parent 86bfb6a commit 1c3043e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/common/datetime/check_time.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ const parseTimeString = (timeString: string, timezone: string): Date => {
2424
throw new Error(`Invalid time values in: ${timeString}`);
2525
}
2626

27+
// Add range validation
28+
if (hours < 0 || hours > 23) {
29+
throw new Error(`Invalid hours in: ${timeString}. Must be 0-23`);
30+
}
31+
if (minutes < 0 || minutes > 59) {
32+
throw new Error(`Invalid minutes in: ${timeString}. Must be 0-59`);
33+
}
34+
if (seconds < 0 || seconds > 59) {
35+
throw new Error(`Invalid seconds in: ${timeString}. Must be 0-59`);
36+
}
37+
2738
const now = new TZDate(new Date(), timezone);
2839
const dateWithTime = new TZDate(
2940
now.getFullYear(),

0 commit comments

Comments
 (0)