Implement a builder API for Now #296
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 newNowBuilder
and any method called onNow
consumes it.For general purpose, a
Temporal
namespace struct was created withnow
andtry_now
methods, which uses theNowBuilder
to construct aNow
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 thenow-builder
branch, but I think this a simpler and cleaner approach than leaning on traits.List of changes:
Now
updated andNowBuilder
added.Temporal
structtime
module renamed tounix_time