Skip to content

Conversation

dfed
Copy link
Contributor

@dfed dfed commented Sep 19, 2025

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
Contributor 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
Contributor 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
Contributor 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:17
Copy link
Contributor

@bsneed bsneed left a 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!!

@bsneed bsneed merged commit c291874 into segmentio:main Oct 13, 2025
1 check passed
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.

2 participants