-
Notifications
You must be signed in to change notification settings - Fork 109
Correct time calculations #401
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
Conversation
| extension TimeInterval { | ||
| static func milliseconds(_ value: Int) -> TimeInterval { | ||
| return TimeInterval(value / 1000) | ||
| return TimeInterval(value) / 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This calculation had an integer-division problem. My change makes it so that we're dividing Double types rather than Int types, and therefore are no longer truncating.
|
|
||
| static func hours(_ value: Int) -> TimeInterval { | ||
| return TimeInterval(60 * value) | ||
| return TimeInterval(60 * 60 * value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a TimeInterval represents a second. There are 60 seconds in a minute, and 60 seconds in an hour.
|
|
||
| static func days(_ value: Int) -> TimeInterval { | ||
| return TimeInterval((60 * value) * 24) | ||
| return TimeInterval((60 * 60 * value) * 24) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
bsneed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man, how embarrassing. Thanks for finding it and fixing!!
All but one of the extensions on
TimeIntervalinQueueTimer.swiftyielded incorrect values.