Skip to content

Commit 0534af3

Browse files
committed
uefi: update set_time() to take generic input
This allows to pass `jiff::{DateTime, Zoned}` and `time::{PrimitiveDateTime,OffsetDateTime}`.
1 parent 9901272 commit 0534af3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

uefi/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
- **Breaking:** Renamed `DevicePathNode::to_string()` to `DevicePathNode::to_string16()`
4949
to better differentiate with the new `to_string()` coming from the new
5050
`Display`.
51+
- `runtime::set_time()` now consumes `&T` where `T: Clone + TryInto<Time>`
52+
instead of `&Time` to improve the integration with other time types.
5153

5254
# uefi - v0.36.1 (2025-11-05)
5355

uefi/src/runtime/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ pub fn get_time_and_caps() -> Result<(Time, TimeCapabilities)> {
7373
///
7474
/// Undefined behavior could happen if multiple tasks try to
7575
/// use this function at the same time without synchronisation.
76-
pub unsafe fn set_time(time: &Time) -> Result {
76+
pub unsafe fn set_time<T: Clone + TryInto<Time>>(time: &T) -> Result {
77+
let time: Time = time
78+
.clone()
79+
.try_into()
80+
.map_err(|_| Status::INVALID_PARAMETER)?;
7781
let rt = runtime_services_raw_panicking();
7882
let rt = unsafe { rt.as_ref() };
7983

80-
let time: *const Time = time;
84+
let time = &raw const time;
8185
unsafe { (rt.set_time)(time.cast()) }.to_result()
8286
}
8387

0 commit comments

Comments
 (0)