]> git.proxmox.com Git - proxmox.git/commitdiff
time: posix: use strftime from the `libc` crate.
authorLukas Wagner <l.wagner@proxmox.com>
Mon, 11 Dec 2023 13:29:04 +0000 (14:29 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 8 Jan 2024 10:57:15 +0000 (11:57 +0100)
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
proxmox-time/src/posix.rs

index 6157f8bcc4c71375838d88bb7e34d2d08981afab..c463ab3a6dfb20dfeb1b5cf17113060ef4d01aad 100644 (file)
@@ -108,25 +108,13 @@ pub fn epoch_f64() -> f64 {
     }
 }
 
-//  rust libc bindings do not include strftime
-#[link(name = "c")]
-extern "C" {
-    #[link_name = "strftime"]
-    fn libc_strftime(
-        s: *mut libc::c_char,
-        max: libc::size_t,
-        format: *const libc::c_char,
-        time: *const libc::tm,
-    ) -> libc::size_t;
-}
-
 /// Safe bindings to libc strftime
 pub fn strftime(format: &str, t: &libc::tm) -> Result<String, Error> {
     let format = CString::new(format).map_err(|err| format_err!("{}", err))?;
     let mut buf = vec![0u8; 8192];
 
     let res = unsafe {
-        libc_strftime(
+        libc::strftime(
             buf.as_mut_ptr() as *mut libc::c_char,
             buf.len() as libc::size_t,
             format.as_ptr(),