public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox] time: fix parsing non-full-hour TZ offsets
Date: Wed, 30 Dec 2020 11:27:41 +0100	[thread overview]
Message-ID: <20201230102741.152274-1-f.gruenbichler@proxmox.com> (raw)

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





             reply	other threads:[~2020-12-30 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-30 10:27 Fabian Grünbichler [this message]
2020-12-31  7:30 ` [pbs-devel] applied: " Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201230102741.152274-1-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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