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

Subtracting DateInRegion returns wrong sign #693

Closed
heikkihautala opened this issue Sep 13, 2019 · 0 comments
Closed

Subtracting DateInRegion returns wrong sign #693

heikkihautala opened this issue Sep 13, 2019 · 0 comments
Assignees
Labels
Milestone

Comments

@heikkihautala
Copy link

SwiftDate 6.0.3

It looks like subtracting DateInRegions has a bug.

Consider the following code:

let today = DateInRegion()
let tomorrow = now + 1.days

// Shouldn't these return equal value?
print(tomorrow - today)
print(tomorrow.timeIntervalSince1970 - today.timeIntervalSince1970)
print(tomorrow.timeIntervalSince(today))

Print output:

-86400.0
86400.0
86400.0

In DateInRegion+Math.swift:

public func - (lhs: DateInRegion, rhs: DateInRegion) -> TimeInterval {
    return rhs.timeIntervalSince(lhs)
}

Shouldn't this return:

lhs.timeIntervalSince(rhs)
@malcommac malcommac added this to the 6.1.0 milestone Sep 14, 2019
@malcommac malcommac self-assigned this Sep 14, 2019
@malcommac malcommac added the bug label Sep 14, 2019
@malcommac malcommac changed the title Subtracting DateInRegions returns wrong sign Subtracting DateInRegion returns wrong sign Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants