Skip to content

Conversation

dfed
Copy link

@dfed dfed commented Sep 19, 2025

Same as segmentio#401, but against this repo: all but one of the extensions on TimeInterval in QueueTimer.swift yielded incorrect values.

extension TimeInterval {
static func milliseconds(_ value: Int) -> TimeInterval {
return TimeInterval(value / 1000)
return TimeInterval(value) / 1000
Copy link
Author

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)
Copy link
Author

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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@dfed dfed marked this pull request as ready for review September 19, 2025 04:21
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

Successfully merging this pull request may close these issues.

1 participant