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] events time math #76

Closed
wants to merge 1 commit into from
Closed

[fix] events time math #76

wants to merge 1 commit into from

Conversation

Arc-blroth
Copy link
Member

sorry ronak for my bad math

@Arc-blroth Arc-blroth requested a review from r2dev2 August 27, 2023 05:22
@bliutech bliutech requested review from bliutech and removed request for bliutech August 27, 2023 05:55
@r2dev2
Copy link
Member

r2dev2 commented Aug 27, 2023

Mentioned in discord but not here, but this fails for today of 08/26/23 and compare with 08/21/23.

@Aplet123 wrote a isSameWeek function that passes my tests that i think should replace the current functions

function isSameWeek(d1, d2) {
    const dayMs = 1000 * 60 * 60 * 24;
    const t1 = d1.getTime();
    const t2 = d2.getTime();
    // cannot be more than a week apart
    if (Math.abs(t1 - t2) >= dayMs * 7) {
        return false;
    }
    const day1 = d1.getDay();
    const day2 = d2.getDay();
    // same day of week = return true iff same date
    if (day1 == day2) {
        return d1.getDate() == d2.getDate();
    } else if (day1 < day2) {
        return t1 < t2;
    } else {
        return t1 > t2;
    }
}

Copy link
Member

@r2dev2 r2dev2 left a comment

Choose a reason for hiding this comment

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

see comment above

@Arc-blroth
Copy link
Member Author

closing in favor of #79

@Arc-blroth Arc-blroth closed this Aug 27, 2023
@bliutech bliutech deleted the fix/eggert-is-crying-rn branch August 27, 2023 08:01
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.

2 participants