Crates.io | time-format |
lib.rs | time-format |
version | 1.1.2 |
source | src |
created_at | 2021-11-09 14:54:54.471273 |
updated_at | 2022-02-14 07:58:37.280342 |
description | Turn a Unix timestamp into date components or into a string. |
homepage | https://github.com/jedisct1/rust-time-format |
repository | https://github.com/jedisct1/rust-time-format |
max_upload_size | |
id | 478899 |
size | 7,948 |
This crate does only one thing: format a Unix timestamp.
The components_utc()
function returns the components of a timestamp:
let ts = time_format::now().unwrap();
let components = time_format::components_utc(ts).unwrap();
Components are sec
, min
, hour
, month_day
, month
, year
, week_day
and year_day
.
The strftime_utc()
function formats a timestamp, using the same format as the strftime()
function of the standard C library.
let ts = time_format::now().unwrap();
let s = time_format::strftime_utc("%Y-%m-%d", ts).unwrap();
If you need a minimal crate to get timestamps and perform basic operations on them, check out coarsetime.
coarsetime
fully supports WebAssembly, in browsers and WASI environments.