Skip to content

Conversation

@gsquire
Copy link
Contributor

@gsquire gsquire commented Mar 13, 2025

This patch migrates some time crate functions to jiff.

I didn't know if the issue describes a wholesale migration or just the linked PR. If it is a full migration, I can mark this as WIP.

This is part of #238.

This patch migrates some time crate functions to jiff.
@gsquire gsquire requested review from a team as code owners March 13, 2025 21:20
@gsquire
Copy link
Contributor Author

gsquire commented Mar 13, 2025

@microsoft-github-policy-service agree

@smalis-msft
Copy link
Contributor

We do want to do a full migration, but taking partial steps towards that goal is still goodness. Thanks for submitting this!

@gsquire
Copy link
Contributor Author

gsquire commented Mar 13, 2025

We do want to do a full migration, but taking partial steps towards that goal is still goodness. Thanks for submitting this!

Got it, I will adjust the PR comment then.

@jstarks jstarks changed the title Move to jiff Crate guest_emulation_device: move to jiff Crate Mar 14, 2025
@jstarks jstarks changed the title guest_emulation_device: move to jiff Crate guest_emulation_device: move to jiff crate Mar 14, 2025
BurntSushi added a commit to BurntSushi/jiff that referenced this pull request Mar 14, 2025
Specifically, that you can't get any units bigger than hours *by
default*.

We also fix what was probably a copy-and-paste error in the `Sub` trait
implementation docs for `Zoned`. (I probably copied it from
`jiff::civil::DateTime`, where it can return days by default.)

And we apply similar clarifications to the `jiff::civil::DateTime` docs
as well.

Ref microsoft/openvmm#1028 (comment)
BurntSushi added a commit to BurntSushi/jiff that referenced this pull request Mar 14, 2025
Specifically, that you can't get any units bigger than hours *by
default*.

We also fix what was probably a copy-and-paste error in the `Sub` trait
implementation docs for `Zoned`. (I probably copied it from
`jiff::civil::DateTime`, where it can return days by default.)

And we apply similar clarifications to the `jiff::civil::DateTime` docs
as well.

Ref microsoft/openvmm#1028 (comment)
@smalis-msft
Copy link
Contributor

The aarch64 unit tests are a known spurious failure we're tracking, but the vmm-test failures look legitimate:

2025-03-14T01:01:08.4258906Z [   openvmm] thread 'basic_device_thread' panicked at vm\devices\get\guest_emulation_device\src\lib.rs:640:14:
2025-03-14T01:01:08.4259516Z [   openvmm] the system timezone to be fixed: cannot convert non-fixed IANA time zone to offset without timestamp or civil datetime


fn handle_time(&mut self) -> Result<(), Error> {
const WINDOWS_EPOCH: time::OffsetDateTime = time::macros::datetime!(1601-01-01 0:00 UTC);
const WINDOWS_EPOCH: DateTime = date(1601, 1, 1).at(0, 0, 0, 0);

Choose a reason for hiding this comment

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

You could do const WINDOWS_EPOCH: Timestamp = Timestamp::constant(-11644473600, 0); here. Then you can avoid doing the to_zoned dance below.

I think I'd be open to adding this constant to Jiff as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we wouldn't want to take that as a hardcoded value unless it was upstreamed, we don't want to be responsible for validating that number haha

Choose a reason for hiding this comment

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

That's fair enough. Yeah otherwise the to_zoned() with the unwrap() is a little unfortunate here. I'll noodle on that one. But it's correct. (The expect() can never fail in this case.)

Copy link
Member

Choose a reason for hiding this comment

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

I'm OK with taking this constant with a unit test. But I think we can do this as a followup change, when we convert the other side of this protocol to jiff, since we use the same constant in that code. We can just define this centrally in the protocol crate used between these two components.

(This will require a little more refactoring, since the GET crate currently exposes this time as the raw i64 instead of interpreting it as a timestamp for its callers, and the callers are the ones with the epoch definitions and conversions. We can centralize that; I am OK with having a jiff::Timestamp in the public API of this internal crate.)

smalis-msft
smalis-msft previously approved these changes Mar 14, 2025
@smalis-msft
Copy link
Contributor

I'll leave this for @jstarks to take one more pass on, but this looks great to me. Thanks again!

@gsquire
Copy link
Contributor Author

gsquire commented Mar 14, 2025

Cool, happy to help. Let me know if you want me to squash my commits.

@smalis-msft
Copy link
Contributor

That's alright, we do squash merges, so github will take care of that.

@smalis-msft smalis-msft enabled auto-merge (squash) March 14, 2025 16:31
@jstarks
Copy link
Member

jstarks commented Mar 14, 2025

Pushed a small formatting change. Thanks again for the change.

@smalis-msft smalis-msft merged commit 358b771 into microsoft:main Mar 14, 2025
26 checks passed
@gsquire gsquire deleted the issue-238 branch March 14, 2025 17: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.

4 participants