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

Slightly different results for dateAt(.endOfDay) and dateAtEndOf(.day) #715

Open
Robuske opened this issue Jan 3, 2020 · 0 comments
Open

Comments

@Robuske
Copy link

Robuske commented Jan 3, 2020

While I was testing something I was not sure if Date().dateAt(.endOfDay) and Date().dateAtEndOf(.day) produced the same result, so I tried comparing them like this

XCTAssertEqual(Date().dateAt(.endOfDay), Date().dateAtEndOf(.day))

Which produced the error

XCTAssertEqual failed: ("2020-01-04 02:59:59 +0000") is not equal to ("2020-01-04 02:59:59 +0000")

Which seemed odd, using

XCTAssertEqual(Date().dateAt(.endOfDay).timeIntervalSince1970, Date().dateAtEndOf(.day).timeIntervalSince1970)

It shows the problem

XCTAssertEqual failed: ("1578106799.0") is not equal to ("1578106799.999")

From what I looked trough, they don't use the same implementation, which does not seem like a good idea and can lead to unexpected problems.

(I realise that date comparison should be done using methods proper for that, but these two should not differ)

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