Crate humantime

source ·
Expand description

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 humantime-serde for serde integration (previous crate serde-humantime looks unmaintained).

Structs

A wrapper for duration that has FromStr implementation
A wrapper type that allows you to Display a Duration
A wrapper type that allows you to Display a SystemTime
A wrapper for SystemTime that has FromStr implementation

Enums

Error parsing human-friendly duration
Error parsing datetime (timestamp)

Functions

Formats duration into a human-readable string
Format an RFC3339 timestamp 2018-02-14T00:28:07Z
Format an RFC3339 timestamp 2018-02-14T00:28:07.000000Z
Format an RFC3339 timestamp 2018-02-14T00:28:07.000Z
Format an RFC3339 timestamp 2018-02-14T00:28:07.000000000Z
Format an RFC3339 timestamp 2018-02-14T00:28:07Z
Parse duration object 1hour 12min 5s
Parse RFC3339 timestamp 2018-02-14T00:28:07Z
Parse RFC3339-like timestamp 2018-02-14 00:28:07