[pbs-devel] [PATCH proxmox 4/5] time/rfc3339: add leading zeroes for years < 1000
Fabian Grünbichler
f.gruenbichler at proxmox.com
Tue Sep 15 12:20:53 CEST 2020
strftime(3) does not mention this explicitly, but years before 1000 have
their leading zero(es) stripped, which is not valid according to either
ISO-8601 or its profile RFC3339.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
proxmox/src/tools/time.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/proxmox/src/tools/time.rs b/proxmox/src/tools/time.rs
index 5747854..3869757 100644
--- a/proxmox/src/tools/time.rs
+++ b/proxmox/src/tools/time.rs
@@ -168,7 +168,7 @@ pub fn epoch_to_rfc3339_utc(epoch: i64) -> Result<String, Error> {
bail!("epoch_to_rfc3339_utc: wrong year '{}'", year);
}
- strftime("%FT%TZ", &gmtime)
+ strftime("%010FT%TZ", &gmtime)
}
/// Convert Unix epoch into RFC3339 local time with TZ
@@ -197,7 +197,7 @@ pub fn epoch_to_rfc3339(epoch: i64) -> Result<String, Error> {
let hours = mins / 60;
let mins = mins % 60;
- let mut s = strftime("%FT%T", &localtime)?;
+ let mut s = strftime("%10FT%T", &localtime)?;
s.push(prefix);
s.push_str(&format!("{:02}:{:02}", hours, mins));
--
2.20.1
More information about the pbs-devel
mailing list