github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/testing/time.go (about)

     1  package testing
     2  
     3  import "time"
     4  
     5  var format = "2006-01-02-15:04:05.999999999 MST"
     6  
     7  func ParseTime(str string) time.Time {
     8  	r, err := time.Parse(format, str+" UTC")
     9  	if err != nil {
    10  		panic(err)
    11  	}
    12  	return r.UTC()
    13  }
    14  
    15  func SimpleTime(i int) time.Time {
    16  	return time.Time{}.Add(time.Duration(i) * time.Second).UTC()
    17  }
    18  
    19  func SimpleUTime(i int) time.Time {
    20  	return time.Unix(int64(i), 0)
    21  }
    22  
    23  func PrintTime(t time.Time) int {
    24  	return int(t.Sub(time.Time{}) / time.Second)
    25  }