whatwg_datetime

Function parse_timezone_offset

Source
pub fn parse_timezone_offset(s: &str) -> Option<TimeZoneOffset>
Expand description

Parse a time-zone offset, with a signed number of hours and minutes

This follows the rules for parsing a time-zone offset string per WHATWG HTML Standard § 2.3.5.6 Time zones.

§Examples

use whatwg_datetime::{parse_timezone_offset, TimeZoneOffset};

// Parse a local datetime string with a date,
// a T delimiter, anda  time with fractional seconds
assert_eq!(
    parse_timezone_offset("-07:00"),
    TimeZoneOffset::new_opt(-7, 0)
);