pub fn timestamp_to_string(timestamp_secs: i64) -> Result<String, std::str::Utf8Error> {
	let gmtime = unsafe { gmtime(&timestamp_secs) };
	let mut buf = [0u8; 4096];

	let format_str = "%Y-%m-%d %H:%M";
	let format_cstr = std::ffi::CString::new(format_str).unwrap();

	let len = unsafe { strftime(buf.as_mut_ptr() as *mut c_char, 4096, format_cstr.as_ptr(), gmtime) };

	std::str::from_utf8(&buf[0..len]).map(|s| s.to_owned())
}
/// Get a String representation for a timestamp.
///
/// # Example
/// ```
/// let current_time = unsafe { libc::time(std::ptr::null_mut()) };
/// let repr = stringutils::timestamp_to_string(current_time).unwrap();
/// println!("Current time: {}", repr);
/// ```
Get a String representation for a timestamp.
Get a String representation for a timestamp .
pub fn timestamp_to_string(timestamp_secs: i64) -> Result<String, std::str::Utf8Error> {
	let gmtime = unsafe { gmtime(&timestamp_secs) };
	let mut buf = [0u8; 4096];
	let format_str = "%Y-%m-%d %H:%M";
	let format_cstr = std::ffi::CString::new(format_str).unwrap();
	let len = unsafe { strftime(buf.as_mut_ptr() as *mut c_char, 4096, format_cstr.as_ptr(), gmtime) };
	std::str::from_utf8(&buf[0..len]).map(|s| s.to_owned())
}
pub fn timestamp_to_string ( timestamp_secs : i64 ) -> Result < String , std :: str :: Utf8Error > { let gmtime = unsafe { gmtime ( & timestamp_secs ) } ; let mut buf = [ 0u8 ; 4096 ] ; let format_str = " " ; let format_cstr = std :: ffi :: CString :: new ( format_str ) . unwrap ( ) ; let len = unsafe { strftime ( buf . as_mut_ptr ( ) as * mut c_char , 4096 , format_cstr . as_ptr ( ) , gmtime ) } ; std :: str :: from_utf8 ( & buf [ 0 .. len ] ) . map ( | s | s . to_owned ( ) ) }
Get a String representation for a timestamp.
Get a String representation for a timestamp .
timestamp_secs
i64
timestamp_secs
i64
example
```
let current_time = unsafe { libc::time(std::ptr::null_mut()) };
let repr = stringutils::timestamp_to_string(current_time).unwrap();
println!("Current time: {}", repr);
```
` ` ` let current_time = unsafe { libc :: time ( std :: ptr :: null_mut () ) } ; let repr = stringutils :: timestamp_to_string ( current_time ) . unwrap () ; println! ( " Current time : {} " repr ) ; ` ` `