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

Comparing with .isTomorrow, .isYesterday, .isLastWeek.. etc is giving wrong value #125

Open
iranjith4 opened this issue Mar 11, 2024 · 1 comment

Comments

@iranjith4
Copy link
Contributor

When comparing yesterday's date with .compare(.isTomorrow), the function is returning true which is wrong.

Example:

let date = Date()
let tomorrow = date.offset(.day, value: 1)!
let yesterday = date.offset(.day, value: -1)!

//In version 5.0.1, these comparison returns `true`, which is a bug. 

if tomorrow.compare(.isYesterday) { 
    print(".isYesterday COMPARISION WRONG")
}

if yesterday.compare(.isTomorrow) {
    print(".isTomorrow COMPARISION WRONG")
}

The same happens for comparing the following DateComparisonType

isYesterday, isTomorrow, isLastWeek, isNextWeek, isLastMonth, isNextMonth, isLastYear, isNextYear 
@iranjith4
Copy link
Contributor Author

Raised a PR #124 with a fix.

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

No branches or pull requests

1 participant