Documentation
¶
Index ¶
- Constants
- Variables
- func Check(year, month, day int) bool
- func First(t time.Time) int64
- func Format(t time.Time, layouts ...string) string
- func FormatLayout(layout string) string
- func IsLeapYear(year int) bool
- func Last(t time.Time) int64
- func Ms() int64
- func Now() time.Time
- func Ns() int64
- func Parse(t string, layouts ...string) (time.Time, error)
- func S() int64
- func SetInterval(fn TimeCallback, timeout time.Duration) (chan interface{}, func())
- func SetTimeout(fn TimeCallback, timeout time.Duration) (chan interface{}, func())
- func Sleep(n int64)
- func StrToTime(s string, layout ...string) (int64, error)
- func String() string
- func TimeToStr(n int64, layout ...string) string
- func Us() int64
- func Usleep(n int64)
- func WithTimeout(fn TimeCallback, timeout time.Duration) (chan interface{}, func())
- type TimeCallback
Constants ¶
View Source
const ( FormatDate = "ymd" FormatDateBar = "y-m-d" FormatTime = "y-m-d h:i:s" FormatTimeJoin = "ymdhis" )
格式化占位符
Variables ¶
View Source
var ( // ErrCanceled is canceled error ErrCanceled = errors.New("xtime: canceled") // ErrTimeouted is timeouted error ErrTimeouted = errors.New("xtime: timeouted") )
Functions ¶
func SetInterval ¶ added in v0.0.4
func SetInterval(fn TimeCallback, timeout time.Duration) (chan interface{}, func())
SetInterval execute the callback every timeout return a chan and cancel func
func SetTimeout ¶ added in v0.0.4
func SetTimeout(fn TimeCallback, timeout time.Duration) (chan interface{}, func())
SetTimeout execute the callback after timeout return a chan and cancel func
func TimeToStr ¶ added in v0.0.4
TimeToStr returns time string of unix timestamp, format in time.Local
func WithTimeout ¶ added in v0.0.4
func WithTimeout(fn TimeCallback, timeout time.Duration) (chan interface{}, func())
WithTimeout execute the callback with timeout return a chan and cancel func
Types ¶
type TimeCallback ¶ added in v0.0.4
type TimeCallback func() interface{}
TimeCallback is a callback with one return value
Click to show internal directories.
Click to hide internal directories.