parse

Function parse 

Source
pub fn parse(input: &str, now: Option<SystemTime>) -> Result<Time, Error>
Expand description

Parse input as any time that Git can parse when inputting a date.

§Examples

§1. SHORT Format

  • 2018-12-24
  • 1970-01-01
  • 1950-12-31
  • 2024-12-31

§2. RFC2822 Format

  • Thu, 18 Aug 2022 12:45:06 +0800
  • Mon Oct 27 10:30:00 2023 -0800

§3. GIT_RFC2822 Format

  • Thu, 8 Aug 2022 12:45:06 +0800
  • Mon Oct 27 10:30:00 2023 -0800 (Note the single-digit day)

§4. ISO8601 Format

  • 2022-08-17 22:04:58 +0200
  • 1970-01-01 00:00:00 -0500

§5. ISO8601_STRICT Format

  • 2022-08-17T21:43:13+08:00

§6. UNIX Timestamp (Seconds Since Epoch)

  • 123456789
  • 0 (January 1, 1970 UTC)
  • -1000
  • 1700000000

§7. Commit Header Format

  • 1745582210 +0200
  • 1660874655 +0800
  • -1660874655 +0800

See also the parse_header().

§8. GITOXIDE Format

  • Thu Sep 04 2022 10:45:06 -0400
  • Mon Oct 27 2023 10:30:00 +0000

§9. DEFAULT Format

  • Thu Sep 4 10:45:06 2022 -0400
  • Mon Oct 27 10:30:00 2023 +0000

§10. Relative Dates (e.g., “2 minutes ago”, “1 hour from now”)

These dates are parsed relative to a now timestamp. The examples depend entirely on the value of now. If now is October 27, 2023 at 10:00:00 UTC: * 2 minutes ago (October 27, 2023 at 09:58:00 UTC) * 3 hours ago (October 27, 2023 at 07:00:00 UTC)