Skip to content

Implement a builder API for Now #296

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

Merged
merged 5 commits into from
May 11, 2025
Merged

Implement a builder API for Now #296

merged 5 commits into from
May 11, 2025

Conversation

nekevss
Copy link
Member

@nekevss nekevss commented May 10, 2025

This PR implements a builder API for now and closes #249.

It has some notable changes to the approach to Now.

Mainly Now is essentially cannot be built without using the new NowBuilder and any method called on Now consumes it.

For general purpose, a Temporal namespace struct was created with now and try_now methods, which uses the NowBuilder to construct a Now with values from the system.

This does differ a bit from the specification in that we are eagerly calling the host system time zone, rather than lazily when the user time zone is None. But I think this can still be worked around on the engine side if lazily calling is preferred and is more a place where the native Rust API will differ from the engine implementation. The work around to this is a trait based approach that is available to see on the now-builder branch, but I think this a simpler and cleaner approach than leaning on traits.

List of changes:

  • Now updated and NowBuilder added.
  • Feature flagged Temporal struct
  • time module renamed to unix_time

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good to me! :)

@nekevss nekevss merged commit cb8ff7b into main May 11, 2025
8 checks passed
@nekevss nekevss deleted the now-builder-take-2 branch May 11, 2025 15:08
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.

Explore a builder pattern API for Now
2 participants