github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/internal/qtest/timestamp_helper.go (about)

     1  package qtest
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/quickfeed/quickfeed/qf"
     8  	"google.golang.org/protobuf/types/known/timestamppb"
     9  )
    10  
    11  // Timestamp returns a protobuf timestamp representation of the given string time.
    12  func Timestamp(t *testing.T, tim string) *timestamppb.Timestamp {
    13  	t.Helper()
    14  	timeTime, err := time.Parse(qf.TimeLayout, tim)
    15  	if err != nil {
    16  		t.Fatal(err)
    17  	}
    18  	return timestamppb.New(timeTime)
    19  }