MachaelLee commented on code in PR #3795:
URL: https://github.com/apache/arrow-rs/pull/3795#discussion_r1124339811


##########
arrow-cast/src/parse.rs:
##########
@@ -614,6 +629,19 @@ mod tests {
             naive_datetime.timestamp_nanos(),
             parse_timestamp("2020-09-08 13:42:29").unwrap()
         );
+
+        let tz: Tz = "+02:00".parse().unwrap();
+        let date = string_to_datetime(&tz, "2020-09-08 13:42:29").unwrap();
+        let utc = date.naive_utc().to_string();
+        assert_eq!(utc, "2020-09-08 11:42:29");
+        let local = date.naive_local().to_string();
+        assert_eq!(local, "2020-09-08 13:42:29");
+
+        let date = string_to_datetime(&tz, "2020-09-08 13:42:29Z").unwrap();
+        let utc = date.naive_utc().to_string();
+        assert_eq!(utc, "2020-09-08 13:42:29");
+        let local = date.naive_local().to_string();
+        assert_eq!(local, "2020-09-08 15:42:29");

Review Comment:
   Add some tests to check timestamp is correct?
   ```suggestion
           assert_eq!(local, "2020-09-08 15:42:29");
           
           let &tz = Local::now().offset();
           let date = string_to_datetime(&tz, "2020-09-08T13:42:29Z").unwrap();
           let dt = 
NaiveDateTime::parse_from_str("2020-09-08T13:42:29Z","%Y-%m-%dT%H:%M:%SZ").unwrap();
           let ts = date.timestamp();
           assert_eq!(dt.timestamp(), ts);
           let date = string_to_datetime(&tz, "2020-09-08 13:42:29").unwrap();
           assert_eq!(dt.timestamp() - (tz.local_minus_utc() as i64), 
date.timestamp());
   ```



-- 
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