6 stable releases

1.1.2 Feb 14, 2022
1.1.1 Jan 19, 2022
1.1.0 Nov 9, 2021
1.0.2 Nov 9, 2021

#504 in Unix APIs

Download history 41/week @ 2023-12-17 42/week @ 2023-12-24 18/week @ 2023-12-31 51/week @ 2024-01-07 43/week @ 2024-01-14 35/week @ 2024-01-21 56/week @ 2024-01-28 45/week @ 2024-02-04 88/week @ 2024-02-11 60/week @ 2024-02-18 56/week @ 2024-02-25 22/week @ 2024-03-03 22/week @ 2024-03-10 13/week @ 2024-03-17 4/week @ 2024-03-24 95/week @ 2024-03-31

138 downloads per month

MIT license

7KB
109 lines

time-format

This crate does only one thing: format a Unix timestamp.

Splitting a timestamp into its components

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.

Formatting a timestamp

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();

That's it

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.


lib.rs:

time-format

This crate does only one thing: format a Unix timestamp.

Splitting a timestamp into its components

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.

Formatting a timestamp

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();

That's it

If you need a minimal crate to get timestamps and perform basic operations on them, check out coarsetime.

No runtime deps