Crate humantime [] [src]

Human-friendly time parser and formatter

Features:

  • Parses durations in free form like 15days 2min 2s
  • Formats durations in similar form 2years 2min 12us
  • Parses and formats timestamp in rfc3339 format: 2018-01-01T12:53:00Z
  • Parses timestamps in a weaker format: 2018-01-01 12:53:00

Timestamp parsing/formatting is super-fast because format is basically fixed.

See serde-humantime for serde integration.

Structs

Duration

A wrapper for duration that has FromStr implementation

FormattedDuration

A wrapper type that allows you to Display a Duration

Rfc3339Timestamp

A wrapper type that allows you to Display a SystemTime

Timestamp

A wrapper for SystemTime that has FromStr implementation

Enums

DurationError

Error parsing human-friendly duration

TimestampError

Error parsing human-friendly timestamp

Functions

format_duration

Formats duration into a human-readable string

format_rfc3339

Format an rfc3339 timestamp 2018-02-14T00:28:07Z

format_rfc3339_nanos

Format an rfc3339 timestamp 2018-02-14T00:28:07.000000000Z

format_rfc3339_seconds

Format an rfc3339 timestamp 2018-02-14T00:28:07Z

parse_duration

Parse duration object 1hour 12min 5s

parse_rfc3339

Parse rfc3339 timestamp 2018-02-14T00:28:07Z

parse_rfc3339_weak

Parse rfc3339-like timestamp 2018-02-14 00:28:07