Newer
Older
use anyhow::Context;
use time::{macros::format_description, Date};
// very basic org mode date parser
pub fn parse_org_date(s: &str) -> anyhow::Result<Date> {
let s = s.strip_prefix('<').context("Invalid date")?;
let s = s.strip_suffix('>').context("Invalid date")?;
let s = s.rsplit_once(' ').context("Invalid date")?.0;
Ok(Date::parse(s, format_description!("[year]-[month]-[day]"))?)
}