Skip to content

Daylight savings offset from UTC

Description

This computes the offset between a time zone and UTC, taking into account daylight saving time. Use $dt$base_utc_offset() to avoid counting DST.

Usage

<Expr>$dt$dst_offset()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  x = as.POSIXct(c("2020-10-25", "2020-10-26"), tz = "Europe/London")
)
df$with_columns(dst_offset = pl$col("x")$dt$dst_offset())
#> shape: (2, 2)
#> ┌─────────────────────────────┬──────────────┐
#> │ x                           ┆ dst_offset   │
#> │ ---                         ┆ ---          │
#> │ datetime[ms, Europe/London] ┆ duration[ms] │
#> ╞═════════════════════════════╪══════════════╡
#> │ 2020-10-25 00:00:00 BST     ┆ 1h           │
#> │ 2020-10-26 00:00:00 GMT     ┆ 0ms          │
#> └─────────────────────────────┴──────────────┘