github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/protocol/time.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package protocol
     4  
     5  // Time is the interface that must implement by any time object.
     6  // It is base on Epoch and Second terms to work anywhere (in any planet in the universe).
     7  // https://en.wikipedia.org/wiki/Epoch
     8  // https://en.wikipedia.org/wiki/Second
     9  type Time interface {
    10  	Epoch() TimeEpoch
    11  	SecondElapsed() int64     // From Epoch
    12  	NanoSecondElapsed() int32 // From second
    13  
    14  	Stringer
    15  }
    16  
    17  type TimeEpoch uint64
    18  
    19  const (
    20  	TimeEpoch_Unset TimeEpoch = iota
    21  	TimeEpoch_Monotonic
    22  	TimeEpoch_Unix
    23  	TimeEpoch_UTC
    24  )
    25  
    26  // A Duration represents the elapsed time between two instants as an int64 nanosecond count.
    27  // The representation limits the largest representable duration to approximately 290 earth years.
    28  type Duration int64