mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-02 14:26:37 +00:00
time: add new epoch_to_http_date
helper
this makes it easy to generate RFC9110 preferred HTTP Dates. Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
This commit is contained in:
parent
68b1396553
commit
316fe71133
@ -380,6 +380,15 @@ pub fn epoch_to_rfc2822(epoch: i64) -> Result<String, Error> {
|
||||
Ok(rfc2822_date)
|
||||
}
|
||||
|
||||
/// Convert an epoch to an RFC9110 preferred HTTP Date format.
|
||||
///
|
||||
/// see: <https://httpwg.org/specs/rfc9110.html#http.date>
|
||||
pub fn epoch_to_http_date(epoch: i64) -> Result<String, Error> {
|
||||
let gmtime = gmtime(epoch)?;
|
||||
let locale = Locale::new(libc::LC_ALL, Locale::C)?;
|
||||
strftime_l("%a, %d %b %Y %H:%M:%S GMT", &gmtime, &locale)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_leap_seconds() {
|
||||
let convert_reconvert = |epoch| {
|
||||
|
Loading…
Reference in New Issue
Block a user