Skip to content

Commit

Permalink
fix: Update timestamp creation for snapshot objects
Browse files Browse the repository at this point in the history
Snapshot Creation timestamp is returned as a "DateTime" string in the
format "2006-01-02 15:04:05" Update code to parse this format instead
of a unix time string, and remove usage of deprecated ptypes.TimestampProto
  • Loading branch information
David-T-White committed Nov 28, 2023
1 parent 1e8293e commit 32b209f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/common/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
package common

import (
"strconv"
"time"

"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
"google.golang.org/protobuf/types/known/timestamppb"
)

// Exos X Storage API Error Codes
Expand Down Expand Up @@ -64,10 +63,10 @@ type SnapshotObject struct {
}

func CreationTimeFromString(creationTime string) (*timestamp.Timestamp, error) {
creationTimestamp, err := strconv.ParseInt(creationTime, 10, 64)
creationTimestamp, err := time.Parse(time.DateTime, creationTime)
if err != nil {
return nil, err
}

return ptypes.TimestampProto(time.Unix(creationTimestamp, 0))
return timestamppb.New(creationTimestamp), nil
}

0 comments on commit 32b209f

Please sign in to comment.