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

DateTimeInterval#duration returns a wrong value #468

Conversation

hackugyo
Copy link

DateTimeInterval#duration returns a negative value when it is initialized with values.
This means DateTimeInterval#end is not equal to the init value.
(iOS10 DateInterval can return correct values.)

@malcommac malcommac changed the base branch from master to feature/4.1.8 September 3, 2017 15:03
@malcommac malcommac self-requested a review September 3, 2017 15:03
@malcommac malcommac self-assigned this Sep 3, 2017
@malcommac malcommac added the bug label Sep 3, 2017
@malcommac malcommac added this to the 4.1.8 milestone Sep 3, 2017
@malcommac malcommac merged commit 7c67eba into malcommac:feature/4.1.8 Sep 3, 2017
@malcommac
Copy link
Owner

Thank you, it will be part of 4.1.8 release

malcommac added a commit that referenced this pull request Sep 3, 2017
@malcommac
Copy link
Owner

malcommac commented Sep 6, 2017

I think we have a problem here, I think I've made a mistake; can you explain me why we can't have DateTimeInterval with negative values?
@hackugyo

@hackugyo
Copy link
Author

hackugyo commented Sep 7, 2017

I've checked #480 and now think we can allow DateTimeInterval with negative values!
The most reason I made PR #468 is from the inconsistency of DateTimeInterval#end. Your 00f9403 solves this inconsistency.
@malcommac

@leviathan
Copy link

let startDate = "10:00"
let endDate = "12:00"

let dateDiff = startDate - endDate

>> raises Exception now in DateTimeInterval #67
>> precondition(end >= start, "Reverse intervals are not allowed")

why should it not be allowed to have a negative time interval ?!

@malcommac
Copy link
Owner

@leviathan I've fixed that, there is not any valid reason to keep this condition. Now DateTimeInterval supports negative interval. See the commit above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants