Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use same timezone to compare #12982

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/web/pages/video/[uid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,12 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
}

//daily.co calls have a 60 minute exit buffer when a user enters a call when it's not available it will trigger the modals
const now = new Date();
const exitDate = new Date(now.getTime() - 60 * 60 * 1000);
const exitDate = dayjs.utc().subtract(1, "hour");
const endTime = dayjs.utc(booking?.endTime);

//find out if the meeting is in the past
const isPast = booking?.endTime <= exitDate;
Copy link
Contributor Author

@Udit-takkar Udit-takkar Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comparison might not work properly because booking.endTime is always in UTC but exitDate in browser's local time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the problem because during this comparison there is a valueOf cast (and it compares the numeric offset from UTC 197..)

Copy link
Contributor Author

@Udit-takkar Udit-takkar Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: exitDate is already in UTC format "2024-01-03T05:49:44.703Z". I thought it's in local time format

const isPast = exitDate.isAfter(endTime);

if (isPast) {
return {
redirect: {
Expand Down
Loading