@@ -17,7 +17,6 @@ use std::mem::MaybeUninit;
1717use std:: time:: { SystemTime , UNIX_EPOCH } ;
1818
1919use crate :: error:: { UResult , USimpleError } ;
20- use crate :: utmpx;
2120
2221/// FFI bindings for libsystemd login and D-Bus functions
2322mod ffi {
@@ -304,18 +303,18 @@ impl SystemdLoginRecord {
304303 }
305304
306305 /// Get login time as time::OffsetDateTime compatible with utmpx
307- pub fn login_time_offset ( & self ) -> utmpx :: time:: OffsetDateTime {
306+ pub fn login_time_offset ( & self ) -> time:: OffsetDateTime {
308307 let duration = self
309308 . login_time
310309 . duration_since ( UNIX_EPOCH )
311310 . unwrap_or_default ( ) ;
312311 let ts_nanos: i128 = ( duration. as_nanos ( ) ) . try_into ( ) . unwrap_or ( 0 ) ;
313- let local_offset = utmpx :: time :: OffsetDateTime :: now_local ( )
314- . map_or_else ( |_| utmpx :: time:: UtcOffset :: UTC , |v| v. offset ( ) ) ;
315- utmpx :: time:: OffsetDateTime :: from_unix_timestamp_nanos ( ts_nanos)
312+ let local_offset =
313+ time :: OffsetDateTime :: now_local ( ) . map_or_else ( |_| time:: UtcOffset :: UTC , |v| v. offset ( ) ) ;
314+ time:: OffsetDateTime :: from_unix_timestamp_nanos ( ts_nanos)
316315 . unwrap_or_else ( |_| {
317- utmpx :: time:: OffsetDateTime :: now_local ( )
318- . unwrap_or_else ( |_| utmpx :: time:: OffsetDateTime :: now_utc ( ) )
316+ time:: OffsetDateTime :: now_local ( )
317+ . unwrap_or_else ( |_| time:: OffsetDateTime :: now_utc ( ) )
319318 } )
320319 . to_offset ( local_offset)
321320 }
@@ -566,7 +565,7 @@ impl SystemdUtmpxCompat {
566565 }
567566
568567 /// Login time
569- pub fn login_time ( & self ) -> utmpx :: time:: OffsetDateTime {
568+ pub fn login_time ( & self ) -> time:: OffsetDateTime {
570569 self . record . login_time_offset ( )
571570 }
572571
@@ -681,7 +680,7 @@ mod tests {
681680 seat_or_tty: "tty1" . to_string( ) ,
682681 raw_device: "tty1" . to_string( ) ,
683682 host: "host1" . to_string( ) ,
684- login_time: std :: time :: UNIX_EPOCH ,
683+ login_time: UNIX_EPOCH ,
685684 pid: 1234 ,
686685 session_leader_pid: 1234 ,
687686 record_type: SystemdRecordType :: UserProcess ,
@@ -692,7 +691,7 @@ mod tests {
692691 seat_or_tty: "pts/0" . to_string( ) ,
693692 raw_device: "pts/0" . to_string( ) ,
694693 host: "host2" . to_string( ) ,
695- login_time: std :: time :: UNIX_EPOCH ,
694+ login_time: UNIX_EPOCH ,
696695 pid: 5678 ,
697696 session_leader_pid: 5678 ,
698697 record_type: SystemdRecordType :: UserProcess ,
@@ -729,7 +728,7 @@ mod tests {
729728 seat_or_tty: "tty1" . to_string( ) ,
730729 raw_device: "tty1" . to_string( ) ,
731730 host: "host1" . to_string( ) ,
732- login_time: std :: time :: UNIX_EPOCH ,
731+ login_time: UNIX_EPOCH ,
733732 pid: 1234 ,
734733 session_leader_pid: 1234 ,
735734 record_type: SystemdRecordType :: UserProcess ,
@@ -753,7 +752,7 @@ mod tests {
753752 seat_or_tty : "seat0" . to_string ( ) ,
754753 raw_device : "seat0" . to_string ( ) ,
755754 host : "localhost" . to_string ( ) ,
756- login_time : std :: time :: UNIX_EPOCH + std:: time:: Duration :: from_secs ( 1000 ) ,
755+ login_time : UNIX_EPOCH + std:: time:: Duration :: from_secs ( 1000 ) ,
757756 pid : 9999 ,
758757 session_leader_pid : 9999 ,
759758 record_type : SystemdRecordType :: UserProcess ,
0 commit comments