[][src]Crate libc_strftime

A wrapper library for the glibc strftime function

Examples

Format the current date and time in Brussels in French:

use std::env;

env::set_var("LC_ALL", "fr_BE.UTF-8");
env::set_var("TZ", "Europe/Brussels");

libc_strftime::tz_set();
libc_strftime::set_locale();

let now = libc_strftime::epoch(); // most likely a u64
let local = libc_strftime::strftime_local("%c", now);
println!("On est: {}", local); // On est: mer 07 aoû 2019 06:19:56 CEST

Functions

epoch

Retrieve the current time in epoch format (number of seconds since 1970 in UTC)

get_gmt_tm_from_epoch

Get a tm struct in GMT

get_local_tm_from_epoch

Get a tm struct in local timezone

set_locale

Call setlocale() which will initialize the locale based on the environment variables

strftime_gmt

Call strftime() using GMT and returns a String

strftime_local

Call strftime() using the local timezone and returns a String

tz_set

Call tzset() which will initialize the local timezone based on the environment variables