whatwg_datetime

Function parse_month_component

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

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

This follows the rules for parsing a month component per WHATWG HTML Standard § 2.3.5.1 Months.

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

§Examples

use whatwg_datetime::{parse_month_component, YearMonth};

let mut position = 0usize;
let date = parse_month_component("2011-11", &mut position);

assert_eq!(date, YearMonth::new_opt(2011, 11));