mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-11 15:29:02 +00:00
time: add test for leap second parsing/converting
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
8cb07ac905
commit
ed7c58cf47
@ -279,3 +279,26 @@ pub fn parse_rfc3339(i: &str) -> Result<i64, Error> {
|
||||
Ok(epoch)
|
||||
}).map_err(|err| format_err!("parse_rfc_3339 failed - {}", err))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_leap_seconds() {
|
||||
let convert_reconvert = |epoch| {
|
||||
let rfc3339 = epoch_to_rfc3339_utc(epoch)
|
||||
.expect("leap second epoch to rfc3339 should work");
|
||||
|
||||
let parsed = parse_rfc3339(&rfc3339)
|
||||
.expect("parsing converted leap second epoch should work");
|
||||
|
||||
assert_eq!(epoch, parsed);
|
||||
};
|
||||
|
||||
// 2005-12-31T23:59:59Z was followed by a leap second
|
||||
let epoch = 1136073599;
|
||||
convert_reconvert(epoch);
|
||||
convert_reconvert(epoch + 1);
|
||||
convert_reconvert(epoch + 2);
|
||||
|
||||
let parsed = parse_rfc3339("2005-12-31T23:59:60Z")
|
||||
.expect("parsing leap second should work");
|
||||
assert_eq!(parsed, epoch + 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user