whatwg_datetime

Function parse_week

Source
pub fn parse_week(input: &str) -> Option<YearWeek>
Expand description

Parse a week-year number and a week-number

This follows the rules for parsing a week string per WHATWG HTML Standard § 2.3.5.8 Weeks.

§Examples

use whatwg_datetime::{parse_week, YearWeek};

assert_eq!(parse_week("2004-W53"), YearWeek::new_opt(2004, 53));
assert_eq!(parse_week("2011-W47"), YearWeek::new_opt(2011, 47));
assert_eq!(parse_week("2011-W53"), None); // 2011 only has 52 weeks