Skip to content

Relax “start time” validation to allow same‐day, later‐today events#214

Open
sahilkashyap64 wants to merge 1 commit intolowercasename:mainfrom
sahilkashyap64:add/relaxstarttime
Open

Relax “start time” validation to allow same‐day, later‐today events#214
sahilkashyap64 wants to merge 1 commit intolowercasename:mainfrom
sahilkashyap64:add/relaxstarttime

Conversation

@sahilkashyap64
Copy link
Copy Markdown

Why

  • Users often want to schedule an event later in the same day. Under the old check, “today at 2 PM” would always fail until the clock passed 2 PM exactly. Switching to a minute‐level comparison lets any time later (even if it’s the same hour) pass validation as soon as the minute boundary has passed.

Testing

  1. Start the server locally (e.g. pnpm run dev on localhost:3000).
  2. Open the “Create event” form and enter a start time that is later in the same day (for example, if it’s 14:00 now, choose 14:30).
  3. Submit. You should no longer see “Start time must be in the future.”
  4. Try selecting a start time that is equal to or before the current minute (e.g. within the same minute). You should still get a validation error.

Notes

  • We preserved the original “cannot schedule an event in the past” rule; we only changed the granularity from “seconds” to “minutes.”
  • No other parts of validateEventData or downstream code were touched.

@Sinetheta
Copy link
Copy Markdown

Hey, I'm here because I had a misconfigured TZ but I figured I would ask a question about your change anyways. Are you sure about the reproduction? I'm able to create events up to any level of precision. The moment code appears to default to a precision of milliseconds https://github.com/moment/moment/blob/master/src/lib/moment/compare.js#L23

actually the first argument is optional and we could just omit the moment() which would mean "now".

new Date();
Tue Jun 03 2025 19:50:24 GMT-0700 (Pacific Daylight Time)
let start = new Date('2025-06-03T19:40');
undefined
moment(start).isSameOrBefore(moment(), "minute");
true
moment(start).isBefore(moment());
true
moment(start).isBefore();
true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants