Skip to content

TimeSpan-Style TimeDuration Constructors in C# Bindings #2778

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

wes-sleeman
Copy link
Contributor

@wes-sleeman wes-sleeman commented May 22, 2025

Description of Changes

This change adds the following System.TimeSpan-style static construction methods to SpacetimeDB.TimeDuration:

  • static TimeDuration FromMilliseconds(double milliseconds)
  • static TimeDuration FromSeconds(double seconds)
  • static TimeDuration FromMinutes(double minutes)
  • static TimeDuration FromHours(double hours)
  • static TimeDuration FromDays(double days)

These mirror the equivalently named static methods on System.TimeSpan and dramatically improve usability and familiarity for experienced C# users with no more overhead than the user performing the multiplication themselves.

Wish I'd thought to do this before v1.1.2 got released. Ah well.

API and ABI breaking changes

None. Convenience methods added in bindings only.

Expected complexity level and risk

1 (potentially up to a low 2 if cleanup is desired elsewhere in the bindings to leverage these new methods).

Testing

  • Ensure the changes build.
  • New contributor check! Review to make sure repo style & substance standards are complied with.

@CLAassistant
Copy link

CLAassistant commented May 22, 2025

CLA assistant check
All committers have signed the CLA.

@bfops bfops requested a review from kazimuth May 23, 2025 15:29
@bfops
Copy link
Collaborator

bfops commented May 27, 2025

Thank you for submitting this! We'll work on getting it reviewed soon.

@wes-sleeman
Copy link
Contributor Author

Thanks! Feel free to merge as-is if you have no problems with it on review. Also very happy to add the equivalent construction helper methods to the Timestamp class (based on the ones in System.DateTime) if that would be helpful? I can do it in this PR or just file a second one…

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