From fe4ef6b05df85390923a5458966259d3dac68827 Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Sun, 5 Feb 2023 21:07:14 -0500 Subject: [PATCH] Add TimestampTime() to ct.SignedTreeHead --- ct/types.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ct/types.go b/ct/types.go index 883e9db..b366fe4 100644 --- a/ct/types.go +++ b/ct/types.go @@ -6,6 +6,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "time" ) const ( @@ -289,6 +290,10 @@ type SignedTreeHead struct { LogID SHA256Hash `json:"log_id"` // The SHA256 hash of the log's public key } +func (sth *SignedTreeHead) TimestampTime() time.Time { + return time.Unix(int64(sth.Timestamp/1000), int64(sth.Timestamp%1000)*1_000_000).UTC() +} + // SignedCertificateTimestamp represents the structure returned by the // add-chain and add-pre-chain methods after base64 decoding. (see RFC sections // 3.2 ,4.1 and 4.2)