public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox] time: fix parsing non-full-hour TZ offsets
@ 2020-12-30 10:27 Fabian Grünbichler
  2020-12-31  7:30 ` [pbs-devel] applied: " Dietmar Maurer
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Grünbichler @ 2020-12-30 10:27 UTC (permalink / raw)
  To: pbs-devel

and add a test case to avoid regressions in the future.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
reported on forum:
https://forum.proxmox.com/threads/backup-not-working-anymore.78406/#post-359935

 proxmox/src/tools/time/mod.rs | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/proxmox/src/tools/time/mod.rs b/proxmox/src/tools/time/mod.rs
index f7ae84f..31174bd 100644
--- a/proxmox/src/tools/time/mod.rs
+++ b/proxmox/src/tools/time/mod.rs
@@ -270,7 +270,7 @@ pub fn parse_rfc3339(input_str: &str) -> Result<i64, Error> {
 
         let hours = check_max(digit(20)? * 10 + digit(21)?, 23)?;
         expect(22, b':')?;
-        let mins = check_max(digit(23)? * 10 + digit(24)?, 23)?;
+        let mins = check_max(digit(23)? * 10 + digit(24)?, 59)?;
 
         let offset = (hours * 3600 + mins * 60) as i64;
 
@@ -385,3 +385,16 @@ fn test_gmtime_range() {
 
     gmtime(upper + 1).expect_err("gmtime should fail for years not fitting into i32");
 }
+
+#[test]
+fn test_timezones() {
+    let input = "2020-12-30T00:00:00+06:30";
+    let epoch = 1609263000;
+    let expected_utc = "2020-12-29T17:30:00Z";
+
+    let parsed = parse_rfc3339(input).expect("parsing failed");
+    assert_eq!(parsed, epoch);
+
+    let res = epoch_to_rfc3339_utc(parsed).expect("converting to RFC failed");
+    assert_eq!(expected_utc, res);
+}
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox] time: fix parsing non-full-hour TZ offsets
  2020-12-30 10:27 [pbs-devel] [PATCH proxmox] time: fix parsing non-full-hour TZ offsets Fabian Grünbichler
@ 2020-12-31  7:30 ` Dietmar Maurer
  0 siblings, 0 replies; 2+ messages in thread
From: Dietmar Maurer @ 2020-12-31  7:30 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Fabian Grünbichler

applied




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-31  7:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30 10:27 [pbs-devel] [PATCH proxmox] time: fix parsing non-full-hour TZ offsets Fabian Grünbichler
2020-12-31  7:30 ` [pbs-devel] applied: " Dietmar Maurer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal