whatwg_datetime

Function parse_timezone_offset_component

Source
pub fn parse_timezone_offset_component(
    s: &str,
    position: &mut usize,
) -> Option<TimeZoneOffset>
Expand description

Low-level function for parsing an individual timezone offset component at a given position

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

Note: This function exposes a lower-level API than parse_timezone_offset. More than likely, you will want to use parse_timezone_offset instead.

§Examples

use whatwg_datetime::{parse_timezone_offset_component, TimeZoneOffset};

let mut position = 0usize;
let date = parse_timezone_offset_component("-07:00", &mut position);

assert_eq!(date, TimeZoneOffset::new_opt(-7, 0));