xtime

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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 Check

func Check(year, month, day int) bool

Check 校验日期有效性

func First

func First(t time.Time) int64

First ...

func Format

func Format(t time.Time, layouts ...string) string

Format ...

func FormatLayout

func FormatLayout(layout string) string

FormatLayout ...

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear 是否是闰年

func Last

func Last(t time.Time) int64

Last ...

func Ms added in v0.0.4

func Ms() int64

Ms returns unix timestamp in Millisecond

func Now added in v0.0.4

func Now() time.Time

Now returns time.Now

func Ns added in v0.0.4

func Ns() int64

Ns returns unix timestamp in Nanosecond

func Parse

func Parse(t string, layouts ...string) (time.Time, error)

Parse ...

func S added in v0.0.4

func S() int64

S returns unix timestamp in Second

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 Sleep added in v0.0.4

func Sleep(n int64)

Sleep n Second

func StrToTime added in v0.0.4

func StrToTime(s string, layout ...string) (int64, error)

StrToTime returns unix timestamp of time string

func String added in v0.0.4

func String() string

String returns string of now

func TimeToStr added in v0.0.4

func TimeToStr(n int64, layout ...string) string

TimeToStr returns time string of unix timestamp, format in time.Local

func Us added in v0.0.4

func Us() int64

Us returns unix timestamp in Microsecond

func Usleep added in v0.0.4

func Usleep(n int64)

Usleep n Microsecond

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL