rune-epoch 0.1.1

Unix timestamp conversions — epoch to human-readable and back
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented8 out of 8 items with examples
  • Size
  • Source code size: 23.02 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 378.91 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • alexile/runes
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • alexile

rune-epoch

Unix timestamp conversions — epoch to human-readable and back.

crates.io docs.rs license CI

What it does

Converts Unix epoch values (seconds or milliseconds) to ISO 8601 UTC strings and back, using pure Rust standard library arithmetic — no external time crates required. Security researchers and log analysts use it to quickly translate raw timestamps found in binary files, database dumps, and network captures into readable dates.

Installation

[dependencies]
rune-epoch = "0.1"

Usage

Library

use rune_epoch::{to_utc_string, from_utc_string, now_secs};

// Current time
println!("{}", now_secs());

// Epoch to string
assert_eq!(to_utc_string(0),          "1970-01-01T00:00:00Z");
assert_eq!(to_utc_string(1704067200), "2024-01-01T00:00:00Z");
assert_eq!(to_utc_string(-86400),     "1969-12-31T00:00:00Z");

// String to epoch
assert_eq!(from_utc_string("2024-01-01T00:00:00Z").unwrap(), 1704067200);
assert_eq!(from_utc_string("2024-01-01 00:00:00").unwrap(),  1704067200);

CLI

cargo install rune-epoch

CLI

rune-epoch                          # print current epoch seconds
rune-epoch --millis                 # print current epoch in milliseconds
rune-epoch 1704067200               # convert epoch to UTC string
rune-epoch "2024-01-15T14:30:00Z"   # convert UTC string to epoch
rune-epoch "2024-01-15 14:30:00"    # space separator also accepted

Output

$ rune-epoch
1704067200

$ rune-epoch 1704067200
2024-01-01T00:00:00Z

$ rune-epoch "2024-01-15T14:30:00Z"
1705329000

$ rune-epoch --millis
1704067200000

License

MIT