-
Notifications
You must be signed in to change notification settings - Fork 221
Conversions between Timestamp and std::time::SystemTime
#835
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
Conversation
src/timestamp.rs
Outdated
| #[cfg(all( | ||
| feature = "std", | ||
| not(miri), | ||
| any( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't need to cfg out these impls on wasm32-unknown-unknown. The value of UNIX_EPOCH on wasm32-unknown-unknown is meaningless, but you also can't construct a SystemTime anyways, so I think leaving these impls is ok, and will be less likely to result in impossible build failures for anyone targeting multiple platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR with those adjustments.
src/timestamp.rs
Outdated
| } | ||
| } | ||
|
|
||
| #[cfg(all(feature = "std", not(miri), not(feature = "js")))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the js feature is likely also unnecessary here. Since it's a no-op outside of wasm32-unknown-unknown, its presence shouldn't have any impact on std-code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
Ah, |
|
The failure appears to be here: |
|
This could be Window's 100ns system time granularity? We could try updating the test case to use |
|
The WASI failure appears to be in the |
Ah, that may be. I've updated the test cases to use 1µs resolution. |
|
The WASI failure is curious. I'd like to see if that test output changes with that latest commit (which should at least resolve the Windows issue). I'll also see about running that test locally so I can iterate on it without it having to go through CI, if needed. I wonder if Edit: I'm able to reproduce it locally. This returns SystemTime::UNIX_EPOCH.checked_sub(Duration::from_nanos(1_000))I'll poke around some more because I'm not familiar with this environment, but perhaps this test should be excluded on that platform? Edit 2: A #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub struct SystemTime(Duration);
pub const UNIX_EPOCH: SystemTime = SystemTime(Duration::from_secs(0));#[stable(feature = "duration", since = "1.3.0")]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[rustc_diagnostic_item = "Duration"]
pub struct Duration {
secs: u64,
nanos: Nanoseconds, // Always 0 <= nanos < NANOS_PER_SEC
}define_valid_range_type! {
pub struct Nanoseconds(u32 as u32 in 0..=999_999_999);
}My proposed solution (and the one I've updated this PR with) is to have that test gracefully exit when the platform running it does not support values < |
KodrAus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working through this @dcormier!
This looks good to me 🙇
|
Thank you! Much appreciated. |
Bumps uuid from 1.17.0 to 1.18.0. Release notes Sourced from uuid's releases. v1.18.0 What's Changed Fix up mismatched_lifetime_syntaxes lint by @KodrAus in uuid-rs/uuid#837 Conversions between Timestamp and std::time::SystemTime by @dcormier in uuid-rs/uuid#835 Wrap the error type used in time conversions by @KodrAus in uuid-rs/uuid#838 Prepare for 1.18.0 release by @KodrAus in uuid-rs/uuid#839 New Contributors @dcormier made their first contribution in uuid-rs/uuid#835 Full Changelog: uuid-rs/[email protected] Commits 60a49eb Merge pull request #839 from uuid-rs/cargo/v1.18.0 eb8c697 prepare for 1.18.0 release 281f26f Merge pull request #838 from uuid-rs/chore/time-conversion 2d67ab2 don't use allocated values in errors c284ed5 wrap the error type used in time conversions 87a4359 Merge pull request #835 from dcormier/main 8927396 Merge pull request #837 from uuid-rs/fix/lifetime-syntaxes 6dfb4b1 Conversions between Timestamp and std::time::SystemTime b508383 fix up mismatched_lifetime_syntaxes lint See full diff in compare view Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase. Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: @dependabot rebase will rebase this PR @dependabot recreate will recreate this PR, overwriting any edits that have been made to it @dependabot merge will merge this PR after your CI passes on it @dependabot squash and merge will squash and merge this PR after your CI passes on it @dependabot cancel merge will cancel a previously requested merge and block automerging @dependabot reopen will reopen this PR if it is closed @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Closes #834.