Crates.io | epoch-converter |
lib.rs | epoch-converter |
version | 0.1.3 |
source | src |
created_at | 2021-11-12 22:34:20.725379 |
updated_at | 2022-02-16 16:28:15.112072 |
description | epoch-converter enables conversion between seconds and units of time as well as between an epoch timestamp and units of time. |
homepage | https://github.com/ellygaytor/epoch-converter |
repository | https://github.com/ellygaytor/epoch-converter |
max_upload_size | |
id | 481168 |
size | 10,699 |
epoch-converter enables conversion between seconds and units of time as well as between an epoch timestamp and units of time.
⚠️ epoch-converter always rounds down.
Add epoch-converter = "0.1.3"
to your Cargo.toml
This function converts a number of seconds into various units of time:
use epoch_converter::units::units;
fn main() {
let seconds = 63115200;
println!("{} years", units(seconds).years); // Print the number of years in 63115200 seconds.
println!("{} months", units(seconds).months); // Print the number of months in 63115200 seconds.
println!("{} days", units(seconds).days); // Print the number of days in 63115200 seconds.
}
This function converts an epoch timestamp into various units of time elapsed since Jan 1, 0001 on the Gregorian calendar:
use epoch_converter::epoch_units::epoch_units;
fn main() {
let epoch = 1278504000;
println!("{} years", epoch_units(epoch).years); // Print the number of years in the epoch timestamp 1278504000.
println!("{} months", epoch_units(epoch).months); // Print the number of months in the epoch timestamp 1278504000.
println!("{} days", epoch_units(epoch).days); // Print the number of days in the epoch timestamp 1278504000.
}