{"record":{"id":"cc2b25de07ad9d51","repo":"pola-rs/polars","slug":"activate-timezones-feature-mod","errorCode":null,"errorMessage":"activate 'timezones' feature","messagePattern":"activate 'timezones' feature","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/chunked_array/temporal/string/mod.rs","lineNumber":291,"sourceCode":"        if tz_aware {\n            #[cfg(feature = \"timezones\")]\n            {\n                let mut convert = LruCachedFunc::new(\n                    |s: &str| {\n                        let dt = DateTime::parse_from_str(s, &fmt).ok()?;\n                        Some(func(dt.naive_utc()))\n                    },\n                    (string_ca.len() as f64).sqrt() as usize,\n                );\n                Ok(\n                    unary_elementwise(string_ca, |opt_s| convert.eval(opt_s?, use_cache))\n                        .with_name(string_ca.name().clone())\n                        .into_datetime(tu, Some(tz.cloned().unwrap_or(TimeZone::UTC))),\n                )\n            }\n            #[cfg(not(feature = \"timezones\"))]\n            {\n                panic!(\"activate 'timezones' feature\")\n            }\n        } else {\n            let transform = match tu {\n                TimeUnit::Nanoseconds => infer::transform_datetime_ns,\n                TimeUnit::Microseconds => infer::transform_datetime_us,\n                TimeUnit::Milliseconds => infer::transform_datetime_ms,\n            };\n            let ca = if strptime::fast_parser_supported(fmt.as_bytes()) {\n                let mut strptime_cache = StrpTimeState::default();\n                let mut convert = LruCachedFunc::new(\n                    |s: &str| match strptime_cache.parse(s.as_bytes(), fmt.as_bytes()) {\n                        None => transform(s, &fmt),\n                        Some(ndt) => Some(func(ndt)),\n                    },\n                    (string_ca.len() as f64).sqrt() as usize,\n                );\n                unary_elementwise(string_ca, |opt_s| convert.eval(opt_s?, use_cache))\n            } else {","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/chunked_array/temporal/string/mod.rs#L273-L309","documentation":"When parsing a string ChunkedArray into a Datetime, if the inferred format indicates a timezone offset the code paths under cfg(feature = \"timezones\") construct a timezone-aware Datetime; with the feature compiled out, the library explicitly panics to say timezone support is missing.","triggerScenarios":"Calling str.to_datetime(...) / cast from String to Datetime on strings containing a timezone offset (e.g. '2024-01-01T00:00:00+02:00') while polars was built without the 'timezones' feature.","commonSituations":"Using the default polars crate features (or the slim polars-core) when your data includes ISO timestamps with 'Z' or '+hh:mm' offsets; CI images built with a reduced feature set.","solutions":["Enable the 'timezones' feature in Cargo.toml: polars = { version = \"...\", features = [\"timezones\", \"temporal\"] }.","Strip the timezone suffix from strings before parsing and parse as naive Datetime.","Parse as Datetime with an explicit format that excludes the offset, or cast to Date instead.","If offsets must be honored, upgrade to a build with 'timezones' (default feature of the full polars meta-crate)."],"exampleFix":"// before\npolars = { version = \"0.40\", default-features = false, features = [\"lazy\", \"temporal\"] }\n// after\npolars = { version = \"0.40\", default-features = false, features = [\"lazy\", \"temporal\", \"timezones\"] }","handlingStrategy":"fallback","validationCode":"// detect tz offsets in the strings you will parse\nlet has_tz = string_series.str()?.contains(\"(Z|[+-]\\d{2}:?\\d{2})$\")?;\nif has_tz && !cfg!(feature = \"timezones\") { /* strip offsets or enable feature */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compile polars with the 'timezones' feature when data contains tz-aware timestamps","Strip 'Z'/+hh:mm suffixes before parsing if tz support is not compiled in","Use str.to_datetime with an explicit offset-free format"],"tags":["polars","panic","timezones","feature-flag"],"backgroundTag":"feature-not-enabled","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}