@@ -92,7 +92,57 @@ pub fn test_gmtime_r_2() {
9292 ( { print_tm_1 ( 1721126096_i64 ) } ) ;
9393 ( { print_tm_1 ( 4102444800_i64 ) } ) ;
9494}
95- pub fn test_strftime_3 ( ) {
95+ pub fn print_local_tm_3 ( t : i64 ) {
96+ let t: Value < i64 > = Rc :: new ( RefCell :: new ( t) ) ;
97+ let tm: Value < libcc2rs:: Tm > = Rc :: new ( RefCell :: new ( Default :: default ( ) ) ) ;
98+ assert ! (
99+ ( ( ( !( ( {
100+ let __res = ( tm. as_pointer( ) ) . clone( ) ;
101+ match jiff:: Timestamp :: from_second( ( t. as_pointer( ) ) . read( ) ) {
102+ Ok ( __ts) => {
103+ let __dt = __ts. to_zoned( jiff:: tz:: TimeZone :: system( ) ) ;
104+ let __info = __dt. time_zone( ) . to_offset_info( __ts) ;
105+ let __zone: Vec <u8 > = __info. abbreviation( ) . bytes( ) . chain( [ 0 ] ) . collect( ) ;
106+ let __isdst = if __info. dst( ) . is_dst( ) { 1 } else { 0 } ;
107+ __res. with_mut( |__tm| {
108+ * __tm = Tm :: from_zoned( & __dt) ;
109+ * __tm. tm_isdst. borrow_mut( ) = __isdst;
110+ * __tm. tm_zone. borrow_mut( ) = Ptr :: alloc_array( __zone. into_boxed_slice( ) ) ;
111+ } ) ;
112+ __res
113+ }
114+ Err ( _) => {
115+ libcc2rs:: cpp2rust_errno( ) . write( :: libc:: EOVERFLOW ) ;
116+ Ptr :: null( )
117+ }
118+ }
119+ } )
120+ . is_null( ) ) ) as i32 )
121+ != 0 )
122+ ) ;
123+ println ! (
124+ "{}-{}-{} {}:{}:{} wday={} yday={} {} gmtoff={} isdst={}" ,
125+ ( * ( * tm. borrow( ) ) . tm_year. borrow( ) ) ,
126+ ( * ( * tm. borrow( ) ) . tm_mon. borrow( ) ) ,
127+ ( * ( * tm. borrow( ) ) . tm_mday. borrow( ) ) ,
128+ ( * ( * tm. borrow( ) ) . tm_hour. borrow( ) ) ,
129+ ( * ( * tm. borrow( ) ) . tm_min. borrow( ) ) ,
130+ ( * ( * tm. borrow( ) ) . tm_sec. borrow( ) ) ,
131+ ( * ( * tm. borrow( ) ) . tm_wday. borrow( ) ) ,
132+ ( * ( * tm. borrow( ) ) . tm_yday. borrow( ) ) ,
133+ ( * ( * tm. borrow( ) ) . tm_zone. borrow( ) ) ,
134+ ( * ( * tm. borrow( ) ) . tm_gmtoff. borrow( ) ) ,
135+ ( * ( * tm. borrow( ) ) . tm_isdst. borrow( ) )
136+ ) ;
137+ }
138+ pub fn test_localtime_r_4 ( ) {
139+ ( { print_local_tm_3 ( 0_i64 ) } ) ;
140+ ( { print_local_tm_3 ( 951782400_i64 ) } ) ;
141+ ( { print_local_tm_3 ( 1704067199_i64 ) } ) ;
142+ ( { print_local_tm_3 ( 1721126096_i64 ) } ) ;
143+ ( { print_local_tm_3 ( 1735689600_i64 ) } ) ;
144+ }
145+ pub fn test_strftime_5 ( ) {
96146 let t: Value < i64 > = Rc :: new ( RefCell :: new ( 1721126096_i64 ) ) ;
97147 let tm: Value < libcc2rs:: Tm > = Rc :: new ( RefCell :: new ( Default :: default ( ) ) ) ;
98148 assert ! (
@@ -263,6 +313,7 @@ pub fn main() {
263313fn main_0 ( ) -> i32 {
264314 ( { test_time_0 ( ) } ) ;
265315 ( { test_gmtime_r_2 ( ) } ) ;
266- ( { test_strftime_3 ( ) } ) ;
316+ ( { test_localtime_r_4 ( ) } ) ;
317+ ( { test_strftime_5 ( ) } ) ;
267318 return 0 ;
268319}
0 commit comments