@@ -985,12 +985,12 @@ fn get_clock_resolution() -> Timestamp {
985985/// as `CLOCK_REALTIME` is required to be supported.
986986/// Failure would indicate a non-conforming or otherwise broken implementation.
987987fn get_clock_resolution ( ) -> Timestamp {
988- use nix :: time:: { ClockId , clock_getres} ;
988+ use rustix :: time:: { ClockId , clock_getres} ;
989989
990- let timespec = clock_getres ( ClockId :: CLOCK_REALTIME ) . unwrap ( ) ;
990+ let timespec = clock_getres ( ClockId :: Realtime ) ;
991991
992- #[ allow( clippy:: unnecessary_cast) ] // Cast required on 32- bit platforms
993- Timestamp :: constant ( timespec. tv_sec ( ) as _ , timespec. tv_nsec ( ) as _ )
992+ #[ allow( clippy:: unnecessary_cast, reason = "needed for 32 bit target" ) ]
993+ Timestamp :: constant ( timespec. tv_sec as _ , timespec. tv_nsec as _ )
994994}
995995
996996#[ cfg( all( unix, target_os = "redox" ) ) ]
@@ -1047,12 +1047,16 @@ fn set_system_datetime(_date: Zoned) -> UResult<()> {
10471047/// `<https://linux.die.net/man/3/clock_settime>`
10481048/// `<https://www.gnu.org/software/libc/manual/html_node/Time-Types.html>`
10491049fn set_system_datetime ( date : Zoned ) -> UResult < ( ) > {
1050- use nix :: { sys :: time:: TimeSpec , time :: ClockId } ;
1050+ use rustix :: time:: { ClockId , Timespec , clock_settime } ;
10511051
10521052 let ts = date. timestamp ( ) ;
1053- let timespec = TimeSpec :: new ( ts. as_second ( ) as _ , ts. subsec_nanosecond ( ) as _ ) ;
1053+ let timespec = Timespec {
1054+ tv_sec : ts. as_second ( ) as _ ,
1055+ tv_nsec : ts. subsec_nanosecond ( ) as _ ,
1056+ } ;
10541057
1055- nix:: time:: clock_settime ( ClockId :: CLOCK_REALTIME , timespec)
1058+ clock_settime ( ClockId :: Realtime , timespec)
1059+ . map_err ( std:: io:: Error :: from)
10561060 . map_err_context ( || translate ! ( "date-error-cannot-set-date" ) )
10571061}
10581062
0 commit comments