Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
appletreeisyellow committed Jun 7, 2024
1 parent 1e8bc26 commit ce4e560
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions datafusion/functions/src/datetime/to_local_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ToLocalTimeFunc {
Some(ts),
Some(tz),
)) => {
let adjusted_ts = adjust_to_local_time(ts, &*tz);
let adjusted_ts = adjust_to_local_time(ts, &tz);
Ok(ColumnarValue::Scalar(ScalarValue::TimestampSecond(
Some(adjusted_ts),
None,
Expand All @@ -81,7 +81,7 @@ impl ToLocalTimeFunc {
Some(ts),
Some(tz),
)) => {
let adjusted_ts = adjust_to_local_time(ts, &*tz);
let adjusted_ts = adjust_to_local_time(ts, &tz);
Ok(ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(
Some(adjusted_ts),
None,
Expand All @@ -91,7 +91,7 @@ impl ToLocalTimeFunc {
Some(ts),
Some(tz),
)) => {
let adjusted_ts = adjust_to_local_time(ts, &*tz);
let adjusted_ts = adjust_to_local_time(ts, &tz);
Ok(ColumnarValue::Scalar(ScalarValue::TimestampMillisecond(
Some(adjusted_ts),
None,
Expand All @@ -101,7 +101,7 @@ impl ToLocalTimeFunc {
Some(ts),
Some(tz),
)) => {
let adjusted_ts = adjust_to_local_time(ts, &*tz);
let adjusted_ts = adjust_to_local_time(ts, &tz);
Ok(ColumnarValue::Scalar(ScalarValue::TimestampMicrosecond(
Some(adjusted_ts),
None,
Expand All @@ -124,7 +124,7 @@ impl ToLocalTimeFunc {
}
}

fn adjust_to_local_time(ts: i64, timezone: &str) -> i64 {
pub fn adjust_to_local_time(ts: i64, timezone: &str) -> i64 {
let tz: Tz = timezone.parse().unwrap();

let date_time = DateTime::from_timestamp_nanos(ts).naive_utc();
Expand All @@ -136,13 +136,13 @@ fn adjust_to_local_time(ts: i64, timezone: &str) -> i64 {

let adjusted_date_time =
date_time.add(TimeDelta::try_seconds(offset_seconds).unwrap());
let adjusted_ts = adjusted_date_time.and_utc().timestamp_nanos_opt().unwrap();

// let adjusted_ts = adjusted_date_time.and_utc().timestamp_nanos_opt().unwrap();
// println!(
// "chunchun - adjust_to_local_time:\ninput timestamp: {:?}\nin NavieDateTime: {:?}\noffset: {:?}\nadjusted_date_time: {:?}\nadjusted_ts: {:?}\n",
// ts, date_time, offset_seconds, adjusted_date_time, adjusted_ts
// );
adjusted_ts
adjusted_date_time.and_utc().timestamp_nanos_opt().unwrap()
}

impl ScalarUDFImpl for ToLocalTimeFunc {
Expand Down

0 comments on commit ce4e560

Please sign in to comment.