From 096b50187a7d86c947a8a87f6b972ad5209bfb28 Mon Sep 17 00:00:00 2001
From: FingerlessGloves <me@FingerlessGloves.me>
Date: Tue, 18 Mar 2025 02:01:37 +0000
Subject: [PATCH] Fix GetTime for GMT users (#13)

UPS failes to use the required `+` when in the GMT timezone. Account for that.

---------

Co-authored-by: Greg T. Wallace <greg@gregtwallace.com>
---
 pkg/apcssh/cmd_gettime.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pkg/apcssh/cmd_gettime.go b/pkg/apcssh/cmd_gettime.go
index 7da6397..139b0ba 100644
--- a/pkg/apcssh/cmd_gettime.go
+++ b/pkg/apcssh/cmd_gettime.go
@@ -28,6 +28,12 @@ func (cli *Client) GetTime() (time.Time, error) {
 	formatUPSVal := datePieces[3]
 	timeZoneVal := datePieces[4]
 
+	// GMT time requires + prefix
+	// APC UPS fails to use the required +, so add it
+	if timeZoneVal == "00:00" {
+		timeZoneVal = "+" + timeZoneVal
+	}
+
 	// known APC UPS format strings
 	dateFormatVal := ""
 	switch formatUPSVal {