Skip to content

Commit

Permalink
✨ Improved time picker logic (#1166)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella authored Jun 19, 2024
1 parent e5be316 commit a1af535
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ const TimePicker: React.FunctionComponent<TimePickerProps> = ({
: dayjs(value).startOf("day");

const res: string[] = [];
while (cursor.isSame(value, "day")) {
res.push(cursor.toISOString());
cursor = cursor.add(15, "minutes");

if (after) {
let cursor = dayjs(after).add(15, "minutes");
while (cursor.diff(after, "hours") < 24) {
res.push(cursor.toISOString());
cursor = cursor.add(15, "minutes");
}
} else {
cursor = dayjs(value).startOf("day");
while (cursor.isSame(value, "day")) {
res.push(cursor.toISOString());
cursor = cursor.add(15, "minutes");
}
}
return res;
}, [after, open, value]);
Expand Down

0 comments on commit a1af535

Please sign in to comment.