tustvold commented on code in PR #5006:
URL: https://github.com/apache/arrow-rs/pull/5006#discussion_r1376269622


##########
parquet_derive/src/parquet_field.rs:
##########
@@ -427,13 +427,9 @@ impl Field {
                 quote! { 
::chrono::naive::NaiveDateTime::from_timestamp_millis(vals[i]).unwrap() }
             }
             Some(ThirdPartyType::ChronoNaiveDate) => {
+                // NaiveDateTime::UNIX_EPOCH.num_days_from_ce() == 719163
                 quote! {
-                    
::chrono::naive::NaiveDate::from_num_days_from_ce_opt(vals[i]
-                + ((::chrono::naive::NaiveDate::from_ymd_opt(1970, 1, 
1).unwrap()
-                        .signed_duration_since(
-                            ::chrono::naive::NaiveDate::from_ymd_opt(0, 12, 
31).unwrap()
-                        )
-                   ).num_days()) as i32).unwrap()
+                    
::chrono::naive::NaiveDate::from_num_days_from_ce_opt(vals[i] + 719163).unwrap()

Review Comment:
   Technically yes, practically no, unless your handling dates in the year 11 
million :smile: 



##########
parquet_derive/src/parquet_field.rs:
##########
@@ -427,13 +427,9 @@ impl Field {
                 quote! { 
::chrono::naive::NaiveDateTime::from_timestamp_millis(vals[i]).unwrap() }
             }
             Some(ThirdPartyType::ChronoNaiveDate) => {
+                // NaiveDateTime::UNIX_EPOCH.num_days_from_ce() == 719163
                 quote! {
-                    
::chrono::naive::NaiveDate::from_num_days_from_ce_opt(vals[i]
-                + ((::chrono::naive::NaiveDate::from_ymd_opt(1970, 1, 
1).unwrap()
-                        .signed_duration_since(
-                            ::chrono::naive::NaiveDate::from_ymd_opt(0, 12, 
31).unwrap()
-                        )
-                   ).num_days()) as i32).unwrap()
+                    
::chrono::naive::NaiveDate::from_num_days_from_ce_opt(vals[i] + 719163).unwrap()

Review Comment:
   Technically yes, practically no, unless you're handling dates in the year 11 
million :smile: 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to