Can download files

This commit is contained in:
2025-04-09 21:26:49 +02:00
parent 61a4ea62c6
commit 6f18aafc33
9 changed files with 126 additions and 5 deletions

View File

@ -1,6 +1,6 @@
//! # Time utilities
use std::time::{SystemTime, UNIX_EPOCH};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
/// Get the current time since epoch
pub fn time() -> u64 {
@ -9,3 +9,13 @@ pub fn time() -> u64 {
.unwrap()
.as_secs()
}
/// Format UNIX time to HTTP date
pub fn unix_to_system_time(time: u64) -> SystemTime {
UNIX_EPOCH + Duration::from_secs(time)
}
/// Format UNIX time to HTTP date
pub fn unix_to_http_date(time: u64) -> String {
httpdate::fmt_http_date(unix_to_system_time(time))
}