Crate epoch_cli

Source
Expand description

epoch-cli is a tool for working with epoch timestamps.

§Features

  • Incredibly fast with low resource usage
  • Only UTC time is used
  • Can work with units of seconds, milliseconds, microseconds, or nanoseconds
  • Can convert epoch timestamps into dates and times
  • Can convert dates and times into epoch timestamps
  • Inspired by https://www.epochconverter.com/

§Documentation

Full documentation, instructions, and API are available at: https://docs.rs/epoch-cli

§Installing with cargo

  1. Install rust
  2. Run cargo install epoch-cli

This will install a binary on your system named epoch.

§Displaying the current epoch time

$ epoch
1585796573

$ epoch --ms
1585796603436

$ epoch --us
1585796667156364

$ epoch --ns
1585796681774366974

§Converting an epoch timestamp to a datetime

$ epoch 1585796573
2020-04-02 03:02:53 UTC

$ epoch --ms 1585796603436
2020-04-02 03:03:23.436 UTC

$ epoch --us 1585796667156364
2020-04-02 03:04:27.156364 UTC

$ epoch --ns 1585796681774366974
2020-04-02 03:04:41.774366974 UTC

§Converting parts of a datetime into an epoch

The full usage looks like epoch --dt year month day [hour] [minute] [second] [millisecond] [microsecond] [nanosecond]

Only year, month, and day are required.

$ epoch --dt 2020 04 01 17 08 55 20 30 40
1585760935

$ epoch --ns --dt 2020 04 01 17 08 55 20 30 40
1585760935020030040

$ epoch --ms --dt 2020 04 01
1585699200000

$ epoch --dt 2020 04 01 23 00 30
1585782030

Modules§

conversions
This module contains methods for converting between time bases.
errors
Error types.

Structs§

DateTimeParts
The parts that make up a date/time.
Epoch
A struct that provides conversions to/from epochs/date/time.