expression

Chrono fixed UTC offset

An offset expresses displacement from UTC, not a region’s historical or future zone rules. Use checked offsets and convert an already known instant. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 1970-01-01T05:30:00+05:30 Common mistake: Treating a fixed offset as a daylight-saving-aware regional time zone.

Formal Syntax & Structure

rust syntaxrust
FixedOffset::east_opt(seconds) -> Option<FixedOffset>

Working Example

Example Snippetrust
fn main() {    use chrono::{DateTime, FixedOffset};    let t = DateTime::from_timestamp(0, 0).unwrap();    let offset = FixedOffset::east_opt(5 * 3600 + 1800).unwrap();    println!("{}", t.with_timezone(&offset).to_rfc3339());}
Rust Reference