rlg::utils

Function parse_datetime

Source
pub fn parse_datetime(datetime_str: &str) -> RlgResult<DateTime>
Expand description

Parses a datetime string in ISO 8601 format.

§Arguments

  • datetime_str - A string slice containing the datetime in ISO 8601 format.

§Returns

A RlgResult<DateTime> which is Ok(DateTime) if parsing succeeds, or an error if parsing fails.

§Examples

use rlg::utils::parse_datetime;

let datetime_str = "2024-08-29T12:00:00Z";
match parse_datetime(datetime_str) {
    Ok(dt) => println!("Parsed datetime: {}", dt),
    Err(e) => eprintln!("Failed to parse datetime: {}", e),
}