Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Mar 28, 2024
1 parent 69ea11f commit 1ad57f2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
6 changes: 3 additions & 3 deletions crates/polars-plan/src/dsl/function_expr/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ fn apply_offsets_to_datetime(
_ => Ok(Int64Chunked::full_null(datetime.0.name(), offsets.len())),
},
(_, 1) => match offsets.get(0) {
Some(offset) => datetime
.0
.try_apply_nonnull_values_generic(|v| offset_fn(&Duration::parse(offset), v, time_zone)),
Some(offset) => datetime.0.try_apply_nonnull_values_generic(|v| {
offset_fn(&Duration::parse(offset), v, time_zone)
}),
_ => Ok(datetime.0.apply(|_| None)),
},
_ => try_binary_elementwise(datetime, offsets, |timestamp_opt, offset_opt| {
Expand Down
23 changes: 11 additions & 12 deletions crates/polars-time/src/month_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,16 @@ impl PolarsMonthEnd for DatetimeChunked {
impl PolarsMonthEnd for DateChunked {
fn month_end(&self, _time_zone: Option<&Tz>) -> PolarsResult<Self> {
const MSECS_IN_DAY: i64 = MILLISECONDS * SECONDS_IN_DAY;
Ok(self
.0
.try_apply_nonnull_values_generic(|t| {
PolarsResult::Ok((roll_forward(
MSECS_IN_DAY * t as i64,
None,
timestamp_ms_to_datetime,
datetime_to_timestamp_ms,
Duration::add_ms,
)? / MSECS_IN_DAY) as i32)
})?
.into_date())
let ret = self.0.try_apply_nonnull_values_generic(|t| {
let fwd = roll_forward(
MSECS_IN_DAY * t as i64,
None,
timestamp_ms_to_datetime,
datetime_to_timestamp_ms,
Duration::add_ms,
)?;
PolarsResult::Ok((fwd / MSECS_IN_DAY) as i32)
})?;
Ok(ret.into_date())
}
}
21 changes: 10 additions & 11 deletions crates/polars-time/src/month_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,15 @@ impl PolarsMonthStart for DatetimeChunked {
impl PolarsMonthStart for DateChunked {
fn month_start(&self, _tz: Option<&Tz>) -> PolarsResult<Self> {
const MSECS_IN_DAY: i64 = MILLISECONDS * SECONDS_IN_DAY;
Ok(self
.0
.try_apply_nonnull_values_generic(|t| {
PolarsResult::Ok((roll_backward(
MSECS_IN_DAY * t as i64,
None,
timestamp_ms_to_datetime,
datetime_to_timestamp_ms,
)? / MSECS_IN_DAY) as i32)
})?
.into_date())
let ret = self.0.try_apply_nonnull_values_generic(|t| {
let bwd = roll_backward(
MSECS_IN_DAY * t as i64,
None,
timestamp_ms_to_datetime,
datetime_to_timestamp_ms,
)?;
PolarsResult::Ok((bwd / MSECS_IN_DAY) as i32)
})?;
Ok(ret.into_date())
}
}
3 changes: 2 additions & 1 deletion crates/polars-time/src/truncate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ impl PolarsTruncate for DatetimeChunked {
}

let w = Window::new(every, every, offset);
self.0.try_apply_nonnull_values_generic(|timestamp| func(&w, timestamp, tz))
self.0
.try_apply_nonnull_values_generic(|timestamp| func(&w, timestamp, tz))
} else {
Ok(Int64Chunked::full_null(self.name(), self.len()))
}
Expand Down

0 comments on commit 1ad57f2

Please sign in to comment.