You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by sh...@apache.org on 2022/02/07 21:06:09 UTC

[trafficcontrol] branch master updated: Adding support for string timestamps (#6542)

This is an automated email from the ASF dual-hosted git repository.

shamrick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 3682943  Adding support for string timestamps (#6542)
3682943 is described below

commit 36829433dabcd7a169d7aaedc41b78b1d004ff7e
Author: Srijeet Chatterjee <30...@users.noreply.github.com>
AuthorDate: Mon Feb 7 14:05:44 2022 -0700

    Adding support for string timestamps (#6542)
---
 lib/go-tc/traffic_stats.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/go-tc/traffic_stats.go b/lib/go-tc/traffic_stats.go
index 69e28da..598db6c 100644
--- a/lib/go-tc/traffic_stats.go
+++ b/lib/go-tc/traffic_stats.go
@@ -255,6 +255,12 @@ func (s TrafficStatsSeries) FormatTimestamps() error {
 				return fmt.Errorf("Datapoint %d (%v) malformed: %v", i, v, err)
 			}
 			s.Values[i][0] = time.Unix(0, val).Format(time.RFC3339)
+		case string:
+			t, err := time.Parse(time.RFC3339, fmt.Sprintf("%v", v[0]))
+			if err != nil {
+				return fmt.Errorf("error converting timestamp %s into RFC3339 format: %v", v[0], err)
+			}
+			s.Values[i][0] = t.String()
 		default:
 			return fmt.Errorf("Invalid type %T for datapoint %d (%v)", v[0], i, v)
 		}