Skip to content

Commit c4a01df

Browse files
Update components/rumi_ai/actions/create-session/create-session.mjs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 16807bc commit c4a01df

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

components/rumi_ai/actions/create-session/create-session.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,20 @@ export default {
7171
summaAI,
7272
} = this;
7373

74-
// Convert date/time inputs to Unix timestamps
75-
// Note: For proper timezone handling, we'd need a library like date-fns-tz
76-
// For now, treating input as local time
74+
// Convert date/time inputs to Unix timestamps with validation
7775
const startDateTime = new Date(`${startDate}T${startTime}:00`);
7876
const endDateTime = new Date(`${endDate || startDate}T${endTime}:00`);
77+
78+
// Validate dates
79+
if (isNaN(startDateTime.getTime())) {
80+
throw new Error("Invalid start date/time provided");
81+
}
82+
if (isNaN(endDateTime.getTime())) {
83+
throw new Error("Invalid end date/time provided");
84+
}
85+
if (endDateTime <= startDateTime) {
86+
throw new Error("End time must be after start time");
87+
}
7988

8089
// Convert to Unix timestamps (seconds since epoch)
8190
const startTimestamp = Math.floor(startDateTime.getTime() / 1000);

0 commit comments

Comments
 (0)