Skip to content

Rename methods on Now and add a test#243

Merged
nekevss merged 3 commits intomainfrom
now-cleanup
Mar 20, 2025
Merged

Rename methods on Now and add a test#243
nekevss merged 3 commits intomainfrom
now-cleanup

Conversation

@nekevss
Copy link
Copy Markdown
Member

@nekevss nekevss commented Mar 12, 2025

This PR adjusts the Now core API and adds a test using mock system data.

The two goals of this PR are the API and implementing at least one more Now test. As far as the API goal, this PR attempts to make the API a bit more explicit and clear. If there's any suggestion for a better method name for the core methods, please feel free to provide feedback.

In the future, we should could add more now unit tests using mock data to ensure the behavior is stable and as expected.

@nekevss nekevss requested a review from jedel1043 March 12, 2025 15:35
@nekevss nekevss added the C-api Changes related to the public API label Mar 12, 2025
Copy link
Copy Markdown
Member

@jedel1043 jedel1043 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!

let system_nanos = sys::get_system_nanoseconds()?;
let epoch_nanos = EpochNanoseconds::try_from(system_nanos)?;
Now::plain_time_iso_with_provider(epoch_nanos, timezone, &*provider)
Now::plain_time_iso_with_provider_and_system_info(epoch_nanos, timezone, &*provider)
Copy link
Copy Markdown
Member

@jedel1043 jedel1043 Mar 20, 2025

Choose a reason for hiding this comment

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

Thought: I'm not against merging this as it is, but I think it would be worth looking into having a builder API instead of two functions with slightly different arguments. Could be hard to have the same semantics through FFI though, so it'd require a bit of thinking.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I'm up for adjustments or rethinking Now's API. A builder pattern could actually be really nice. The main goal here was to mostly align the method names a little bit better with the rest of the crate and add tests.

I'm really not in love with the names, but at the very least they are specific. We should open an issue for the builder pattern.

@nekevss nekevss merged commit b244cba into main Mar 20, 2025
8 checks passed
@nekevss nekevss deleted the now-cleanup branch March 20, 2025 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-api Changes related to the public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants