Skip to content

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

License

Notifications You must be signed in to change notification settings

jedisct1/rust-time-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages