parse_datetime

Function parse_datetime 

Source
pub fn parse_datetime<S: AsRef<str> + Clone>(
    input: S,
) -> Result<Zoned, ParseDateTimeError>
Expand description

Parses a time string and returns a Zoned object representing the absolute time of the string.

§Arguments

  • input - A string slice representing the time.

§Examples

use jiff::Zoned;
use parse_datetime::parse_datetime;

let time = parse_datetime("2023-06-03 12:00:01Z").unwrap();
assert_eq!(time.strftime("%F %T").to_string(), "2023-06-03 12:00:01");

§Returns

  • Ok(Zoned) - If the input string can be parsed as a time
  • Err(ParseDateTimeError) - If the input string cannot be parsed as a relative time

§Errors

This function will return Err(ParseDateTimeError::InvalidInput) if the input string cannot be parsed as a relative time.