github.com/lingyao2333/mo-zero@v1.4.1/core/timex/relativetime.go (about)

     1  package timex
     2  
     3  import "time"
     4  
     5  // Use the long enough past time as start time, in case timex.Now() - lastTime equals 0.
     6  var initTime = time.Now().AddDate(-1, -1, -1)
     7  
     8  // Now returns a relative time duration since initTime, which is not important.
     9  // The caller only needs to care about the relative value.
    10  func Now() time.Duration {
    11  	return time.Since(initTime)
    12  }
    13  
    14  // Since returns a diff since given d.
    15  func Since(d time.Duration) time.Duration {
    16  	return time.Since(initTime) - d
    17  }