Documentation ¶
Overview ¶
Package time provides time-zone and local-machine independent time service
Index ¶
- func InitTimeSync()
- type TimeService
- type TimeStamp
- func (ts TimeStamp) AddMilliSeconds(milliSec int64) TimeStamp
- func (ts TimeStamp) AddSeconds(sec int64) TimeStamp
- func (ts TimeStamp) After(t TimeStamp) bool
- func (ts TimeStamp) Bytes() []byte
- func (ts TimeStamp) Local() time.Time
- func (ts TimeStamp) SinceMilliSeconds(t TimeStamp) int64
- func (ts TimeStamp) SinceSeconds(t TimeStamp) int64
- func (ts TimeStamp) String() string
- func (ts TimeStamp) UTC() time.Time
- func (ts TimeStamp) Unix() int64
- func (ts TimeStamp) UnixMilli() int64
- type TimeSync
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitTimeSync ¶
func InitTimeSync()
Types ¶
type TimeService ¶
type TimeService interface { // Now returns the current timestamp calibrated with ntp server Now() TimeStamp // SinceSeconds returns the time duration from the given timestamp to current moment SinceSeconds(t TimeStamp) int64 // NowAfter checks if current timestamp greater than the given one NowAfter(t TimeStamp) bool }
TimeService is a time service, it return a timestamp in seconds
var TSInstance TimeService
type TimeStamp ¶
type TimeStamp int64
TimeStamp in milliseconds
func TimeToTimeStamp ¶
func (TimeStamp) AddMilliSeconds ¶
func (TimeStamp) AddSeconds ¶
func (TimeStamp) SinceMilliSeconds ¶
func (TimeStamp) SinceSeconds ¶
type TimeSync ¶
type TimeSync struct {
// contains filtered or unexported fields
}
TimeSync implements time synchronization from ntp servers
func (*TimeSync) SinceSeconds ¶
SinceSeconds returns the time duration seconds from the given timestamp to current moment
Click to show internal directories.
Click to hide internal directories.