@@ -75,23 +75,11 @@ pub fn print_tm_2(t: i64) {
7575 let tm: Value < libcc2rs:: Tm > = Rc :: new ( RefCell :: new ( Default :: default ( ) ) ) ;
7676 assert ! (
7777 ( ( ( !( ( {
78- let __res = ( tm. as_pointer( ) ) ;
78+ let __res = ( tm. as_pointer( ) ) . clone ( ) ;
7979 match jiff:: Timestamp :: from_second( ( t. as_pointer( ) ) . read( ) ) {
8080 Ok ( __ts) => {
8181 let __dt = __ts. to_zoned( jiff:: tz:: TimeZone :: UTC ) ;
82- __res. with_mut( |__tm| {
83- * __tm. tm_sec. borrow_mut( ) = __dt. second( ) as i32 ;
84- * __tm. tm_min. borrow_mut( ) = __dt. minute( ) as i32 ;
85- * __tm. tm_hour. borrow_mut( ) = __dt. hour( ) as i32 ;
86- * __tm. tm_mday. borrow_mut( ) = __dt. day( ) as i32 ;
87- * __tm. tm_mon. borrow_mut( ) = __dt. month( ) as i32 - 1 ;
88- * __tm. tm_year. borrow_mut( ) = __dt. year( ) as i32 - 1900 ;
89- * __tm. tm_wday. borrow_mut( ) = __dt. weekday( ) . to_sunday_zero_offset( ) as i32 ;
90- * __tm. tm_yday. borrow_mut( ) = __dt. day_of_year( ) as i32 - 1 ;
91- * __tm. tm_isdst. borrow_mut( ) = 0 ;
92- * __tm. tm_gmtoff. borrow_mut( ) = 0 ;
93- * __tm. tm_zone. borrow_mut( ) = Ptr :: from_string_literal( b"GMT" ) ;
94- } ) ;
82+ __res. with_mut( |__tm| * __tm = Tm :: from_zoned( & __dt) ) ;
9583 __res
9684 }
9785 Err ( _) => {
@@ -104,15 +92,18 @@ pub fn print_tm_2(t: i64) {
10492 != 0 )
10593 ) ;
10694 println ! (
107- "{}-{}-{} {}:{}:{} wday={} yday={}" ,
95+ "{}-{}-{} {}:{}:{} wday={} yday={} {} gmtoff={} isdst={} " ,
10896 ( * ( * tm. borrow( ) ) . tm_year. borrow( ) ) ,
10997 ( * ( * tm. borrow( ) ) . tm_mon. borrow( ) ) ,
11098 ( * ( * tm. borrow( ) ) . tm_mday. borrow( ) ) ,
11199 ( * ( * tm. borrow( ) ) . tm_hour. borrow( ) ) ,
112100 ( * ( * tm. borrow( ) ) . tm_min. borrow( ) ) ,
113101 ( * ( * tm. borrow( ) ) . tm_sec. borrow( ) ) ,
114102 ( * ( * tm. borrow( ) ) . tm_wday. borrow( ) ) ,
115- ( * ( * tm. borrow( ) ) . tm_yday. borrow( ) )
103+ ( * ( * tm. borrow( ) ) . tm_yday. borrow( ) ) ,
104+ ( * ( * tm. borrow( ) ) . tm_zone. borrow( ) ) ,
105+ ( * ( * tm. borrow( ) ) . tm_gmtoff. borrow( ) ) ,
106+ ( * ( * tm. borrow( ) ) . tm_isdst. borrow( ) )
116107 ) ;
117108}
118109pub fn test_gmtime_r_3 ( ) {
@@ -132,23 +123,11 @@ pub fn test_strftime_4() {
132123 let tm: Value < libcc2rs:: Tm > = Rc :: new ( RefCell :: new ( Default :: default ( ) ) ) ;
133124 assert ! (
134125 ( ( ( !( ( {
135- let __res = ( tm. as_pointer( ) ) ;
126+ let __res = ( tm. as_pointer( ) ) . clone ( ) ;
136127 match jiff:: Timestamp :: from_second( ( t. as_pointer( ) ) . read( ) ) {
137128 Ok ( __ts) => {
138129 let __dt = __ts. to_zoned( jiff:: tz:: TimeZone :: UTC ) ;
139- __res. with_mut( |__tm| {
140- * __tm. tm_sec. borrow_mut( ) = __dt. second( ) as i32 ;
141- * __tm. tm_min. borrow_mut( ) = __dt. minute( ) as i32 ;
142- * __tm. tm_hour. borrow_mut( ) = __dt. hour( ) as i32 ;
143- * __tm. tm_mday. borrow_mut( ) = __dt. day( ) as i32 ;
144- * __tm. tm_mon. borrow_mut( ) = __dt. month( ) as i32 - 1 ;
145- * __tm. tm_year. borrow_mut( ) = __dt. year( ) as i32 - 1900 ;
146- * __tm. tm_wday. borrow_mut( ) = __dt. weekday( ) . to_sunday_zero_offset( ) as i32 ;
147- * __tm. tm_yday. borrow_mut( ) = __dt. day_of_year( ) as i32 - 1 ;
148- * __tm. tm_isdst. borrow_mut( ) = 0 ;
149- * __tm. tm_gmtoff. borrow_mut( ) = 0 ;
150- * __tm. tm_zone. borrow_mut( ) = Ptr :: from_string_literal( b"GMT" ) ;
151- } ) ;
130+ __res. with_mut( |__tm| * __tm = Tm :: from_zoned( & __dt) ) ;
152131 __res
153132 }
154133 Err ( _) => {
@@ -165,17 +144,7 @@ pub fn test_strftime_4() {
165144 ) ) ;
166145 assert ! (
167146 ( ( ( {
168- let __dt = ( tm. as_pointer( ) ) . with( |__tm| {
169- jiff:: civil:: DateTime :: new(
170- ( * __tm. tm_year. borrow( ) + 1900 ) as i16 ,
171- ( * __tm. tm_mon. borrow( ) + 1 ) as i8 ,
172- * __tm. tm_mday. borrow( ) as i8 ,
173- * __tm. tm_hour. borrow( ) as i8 ,
174- * __tm. tm_min. borrow( ) as i8 ,
175- * __tm. tm_sec. borrow( ) as i8 ,
176- 0 ,
177- )
178- } ) ;
147+ let __dt = ( tm. as_pointer( ) ) . with( |__tm| __tm. to_civil( ) ) ;
179148 let __text = match __dt {
180149 Ok ( __d) => jiff:: fmt:: strtime:: format(
181150 Ptr :: from_string_literal( b"%Y-%m-%d %H:%M:%S" )
@@ -203,17 +172,7 @@ pub fn test_strftime_4() {
203172 println ! ( "{}" , ( buf. as_pointer( ) as Ptr :: <u8 >) ) ;
204173 assert ! (
205174 ( ( ( {
206- let __dt = ( tm. as_pointer( ) ) . with( |__tm| {
207- jiff:: civil:: DateTime :: new(
208- ( * __tm. tm_year. borrow( ) + 1900 ) as i16 ,
209- ( * __tm. tm_mon. borrow( ) + 1 ) as i8 ,
210- * __tm. tm_mday. borrow( ) as i8 ,
211- * __tm. tm_hour. borrow( ) as i8 ,
212- * __tm. tm_min. borrow( ) as i8 ,
213- * __tm. tm_sec. borrow( ) as i8 ,
214- 0 ,
215- )
216- } ) ;
175+ let __dt = ( tm. as_pointer( ) ) . with( |__tm| __tm. to_civil( ) ) ;
217176 let __text = match __dt {
218177 Ok ( __d) => jiff:: fmt:: strtime:: format(
219178 Ptr :: from_string_literal( b"%a, %d %b %Y %T" )
@@ -241,17 +200,7 @@ pub fn test_strftime_4() {
241200 println ! ( "{}" , ( buf. as_pointer( ) as Ptr :: <u8 >) ) ;
242201 assert ! (
243202 ( ( ( {
244- let __dt = ( tm. as_pointer( ) ) . with( |__tm| {
245- jiff:: civil:: DateTime :: new(
246- ( * __tm. tm_year. borrow( ) + 1900 ) as i16 ,
247- ( * __tm. tm_mon. borrow( ) + 1 ) as i8 ,
248- * __tm. tm_mday. borrow( ) as i8 ,
249- * __tm. tm_hour. borrow( ) as i8 ,
250- * __tm. tm_min. borrow( ) as i8 ,
251- * __tm. tm_sec. borrow( ) as i8 ,
252- 0 ,
253- )
254- } ) ;
203+ let __dt = ( tm. as_pointer( ) ) . with( |__tm| __tm. to_civil( ) ) ;
255204 let __text = match __dt {
256205 Ok ( __d) => jiff:: fmt:: strtime:: format(
257206 Ptr :: from_string_literal( b"day %j 100%%" )
@@ -279,17 +228,7 @@ pub fn test_strftime_4() {
279228 println ! ( "{}" , ( buf. as_pointer( ) as Ptr :: <u8 >) ) ;
280229 assert ! (
281230 ( ( ( {
282- let __dt = ( tm. as_pointer( ) ) . with( |__tm| {
283- jiff:: civil:: DateTime :: new(
284- ( * __tm. tm_year. borrow( ) + 1900 ) as i16 ,
285- ( * __tm. tm_mon. borrow( ) + 1 ) as i8 ,
286- * __tm. tm_mday. borrow( ) as i8 ,
287- * __tm. tm_hour. borrow( ) as i8 ,
288- * __tm. tm_min. borrow( ) as i8 ,
289- * __tm. tm_sec. borrow( ) as i8 ,
290- 0 ,
291- )
292- } ) ;
231+ let __dt = ( tm. as_pointer( ) ) . with( |__tm| __tm. to_civil( ) ) ;
293232 let __text = match __dt {
294233 Ok ( __d) => jiff:: fmt:: strtime:: format(
295234 Ptr :: from_string_literal( b"%e" ) . to_rust_string( ) . as_str( ) ,
@@ -318,17 +257,7 @@ pub fn test_strftime_4() {
318257 ) ) ;
319258 assert ! (
320259 ( ( ( {
321- let __dt = ( tm. as_pointer( ) ) . with( |__tm| {
322- jiff:: civil:: DateTime :: new(
323- ( * __tm. tm_year. borrow( ) + 1900 ) as i16 ,
324- ( * __tm. tm_mon. borrow( ) + 1 ) as i8 ,
325- * __tm. tm_mday. borrow( ) as i8 ,
326- * __tm. tm_hour. borrow( ) as i8 ,
327- * __tm. tm_min. borrow( ) as i8 ,
328- * __tm. tm_sec. borrow( ) as i8 ,
329- 0 ,
330- )
331- } ) ;
260+ let __dt = ( tm. as_pointer( ) ) . with( |__tm| __tm. to_civil( ) ) ;
332261 let __text = match __dt {
333262 Ok ( __d) => jiff:: fmt:: strtime:: format(
334263 Ptr :: from_string_literal( b"%Y-%m-%d" )
0 commit comments