jayzhan211 commented on code in PR #6755:
URL: https://github.com/apache/arrow-rs/pull/6755#discussion_r1849527182
##########
arrow-array/src/temporal_conversions.rs:
##########
@@ -134,6 +146,31 @@ pub fn timestamp_s_to_datetime(v: i64) ->
Option<NaiveDateTime> {
Some(DateTime::from_timestamp(v, 0)?.naive_utc())
}
+/// Similar to timestamp_s_to_datetime but only compute `date`
+#[inline]
+pub fn timestamp_s_to_date(secs: i64) -> Option<NaiveDateTime> {
+ let days = secs.div_euclid(86_400) + UNIX_EPOCH_DAY;
+ if days < i32::MIN as i64 || days > i32::MAX as i64 {
+ return None;
+ }
+ let date = NaiveDate::from_num_days_from_ce_opt(days as i32)?;
+ Some(date.and_time(NaiveTime::default()).and_utc().naive_utc())
+}
+
+/// Similar to timestamp_s_to_datetime but only compute `time`
+#[inline]
+pub fn timestamp_s_to_time(secs: i64) -> Option<NaiveDateTime> {
+ let secs = secs.rem_euclid(86_400);
Review Comment:
Let's support it when chrono did so.
--
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]