Skip to content

Add Publishers.AgainAt.Timer.time(at:) - #30

Merged
atdrendel merged 4 commits into
mainfrom
again-at-follow-up
May 3, 2026
Merged

Add Publishers.AgainAt.Timer.time(at:)#30
atdrendel merged 4 commits into
mainfrom
again-at-follow-up

Conversation

@atdrendel

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 3, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a convenience API to Publishers.AgainAt.Timer for converting a wall-clock Date into the scheduler’s SchedulerTimeType, enabling republish(at:) to be driven by Date values.

Changes:

  • Add Publishers.AgainAt.Timer.time(at:) to convert a Date into Context.SchedulerTimeType.
  • Add overflow-clamped TimeInterval -> nanoseconds conversion helper.
  • Add tests covering future date scheduling, past date behavior, and distant-future overflow behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
Sources/CombineExtensions/AgainAt.swift Adds Timer.time(at:) plus nanosecond conversion/clamping to safely build scheduler times from Date.
Tests/CombineExtensionsTests/AgainAtTests.swift Adds new unit tests validating date-to-scheduler-time conversion behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Tests/CombineExtensionsTests/AgainAtTests.swift Outdated
Comment on lines +355 to +363
private extension TimeInterval {
var nanoseconds: Int {
guard self > 0 else { return 0 }
let nanoseconds = self * 1_000_000_000
guard nanoseconds < Double(maxNanoseconds) else {
return maxNanoseconds
}
return Int(nanoseconds)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Applied in 6e636c9. The conversion now uses .rounded(.up) (ceiling) so time(at:) never schedules before the requested Date. Also added a comment on maxNanoseconds explaining the overflow headroom.

Comment thread Sources/CombineExtensions/AgainAt.swift
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread Sources/CombineExtensions/AgainAt.swift Outdated
@atdrendel
atdrendel merged commit 8ecbf23 into main May 3, 2026
2 checks passed
@atdrendel
atdrendel deleted the again-at-follow-up branch May 3, 2026 20:04
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.

3 participants