12 releases (2 stable)
1.0.1 | Mar 7, 2023 |
---|---|
1.0.0 | Apr 8, 2022 |
0.2.1 | Sep 27, 2021 |
0.2.0 | Jan 15, 2021 |
0.1.1 | Apr 2, 2020 |
#420 in Date and time
18KB
338 lines
epoch-cli
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
lib.rs
:
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
- Install rust
- 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
Dependencies
~1.8–2.4MB
~45K SLoC