Documentation
¶
Overview ¶
Package gxtime encapsulates some golang.time functions
Package gxtime encapsulates some golang.time functions refer to github.com/jinzhu/now
Package gxtime encapsulates some golang.time functions ¶
Package gxtime encapsulates some golang.time functions refer to github.com/jehiah/go-strftime
Package gxtime encapsulates some golang.time functions ¶
Package gxtime encapsulates some golang.time functions ¶
Package gxtime encapsulates some golang.time functions ¶
Package gxtime encapsulates some golang.time functions ref: https://github.com/AlexStocks/go-practice/blob/master/time/siddontang_time_wheel.go
Example ¶
time.Now() // 2013-11-18 17:51:49.123456789 Mon BeginningOfMinute() // 2013-11-18 17:51:00 Mon BeginningOfHour() // 2013-11-18 17:00:00 Mon BeginningOfDay() // 2013-11-18 00:00:00 Mon BeginningOfWeek() // 2013-11-17 00:00:00 Sun FirstDayMonday = true // Set Monday as first day BeginningOfWeek() // 2013-11-18 00:00:00 Mon BeginningOfMonth() // 2013-11-01 00:00:00 Fri BeginningOfQuarter() // 2013-10-01 00:00:00 Tue BeginningOfYear() // 2013-01-01 00:00:00 Tue EndOfMinute() // 2013-11-18 17:51:59.999999999 Mon EndOfHour() // 2013-11-18 17:59:59.999999999 Mon EndOfDay() // 2013-11-18 23:59:59.999999999 Mon EndOfWeek() // 2013-11-23 23:59:59.999999999 Sat FirstDayMonday = true // Set Monday as first day EndOfWeek() // 2013-11-24 23:59:59.999999999 Sun EndOfMonth() // 2013-11-30 23:59:59.999999999 Sat EndOfQuarter() // 2013-12-31 23:59:59.999999999 Tue EndOfYear() // 2013-12-31 23:59:59.999999999 Tue // Use another time t := time.Date(2013, 02, 18, 17, 51, 49, 123456789, time.UTC) NewGxTime(t).EndOfMonth() // 2013-02-28 23:59:59.999999999 Thu Monday() // 2013-11-18 00:00:00 Mon Sunday() // 2013-11-24 00:00:00 Sun EndOfSunday() // 2013-11-24 23:59:59.999999999 Sun
Output:
Index ¶
- Constants
- Variables
- func After(d time.Duration) <-chan time.Time
- func BeginningOfDay() time.Time
- func BeginningOfHour() time.Time
- func BeginningOfMinute() time.Time
- func BeginningOfMonth() time.Time
- func BeginningOfQuarter() time.Time
- func BeginningOfWeek() time.Time
- func BeginningOfYear() time.Time
- func Between(time1, time2 string) bool
- func EndOfDay() time.Time
- func EndOfHour() time.Time
- func EndOfMinute() time.Time
- func EndOfMonth() time.Time
- func EndOfQuarter() time.Time
- func EndOfSunday() time.Time
- func EndOfWeek() time.Time
- func EndOfYear() time.Time
- func Format(format string, t time.Time) string
- func Future(sec int, f func())
- func GetEndtime(format string) time.Time
- func Init()
- func Monday() time.Time
- func MustParse(strs ...string) time.Time
- func MustParseInLocation(loc *time.Location, strs ...string) time.Time
- func Now() time.Time
- func Parse(strs ...string) (time.Time, error)
- func ParseInLocation(loc *time.Location, strs ...string) (time.Time, error)
- func Sleep(d time.Duration)
- func Sunday() time.Time
- func Tick(d time.Duration) <-chan time.Time
- func Time2Unix(t time.Time) int64
- func Time2UnixNano(t time.Time) int64
- func TimeDayDuratioin(day float64) time.Duration
- func TimeHourDuratioin(hour float64) time.Duration
- func TimeMicrosecondDuration(m float64) time.Duration
- func TimeMillisecondDuration(m float64) time.Duration
- func TimeMinuteDuration(minute float64) time.Duration
- func TimeNanosecondDuration(n float64) time.Duration
- func TimeSecondDuration(sec float64) time.Duration
- func Unix2Time(unix int64) time.Time
- func UnixNano2Time(nano int64) time.Time
- func UnixString2Time(unix string) time.Time
- func YMD(year int, month int, day int, hour int, minute int, sec int) int
- func YMDPrint(sec int, nsec int) string
- func YMDUTC(year int, month int, day int, hour int, minute int, sec int) int
- type CountWatch
- type GxTime
- func (now *GxTime) BeginningOfDay() time.Time
- func (now *GxTime) BeginningOfHour() time.Time
- func (now *GxTime) BeginningOfMinute() time.Time
- func (now *GxTime) BeginningOfMonth() time.Time
- func (now *GxTime) BeginningOfQuarter() time.Time
- func (now *GxTime) BeginningOfWeek() time.Time
- func (now *GxTime) BeginningOfYear() time.Time
- func (now *GxTime) Between(time1, time2 string) bool
- func (now *GxTime) EndOfDay() time.Time
- func (now *GxTime) EndOfHour() time.Time
- func (now *GxTime) EndOfMinute() time.Time
- func (now *GxTime) EndOfMonth() time.Time
- func (now *GxTime) EndOfQuarter() time.Time
- func (now *GxTime) EndOfSunday() time.Time
- func (now *GxTime) EndOfWeek() time.Time
- func (now *GxTime) EndOfYear() time.Time
- func (now *GxTime) Monday() time.Time
- func (now *GxTime) MustParse(strs ...string) (t time.Time)
- func (now *GxTime) Parse(strs ...string) (t time.Time, err error)
- func (now *GxTime) Sunday() time.Time
- type Ticker
- type Timer
- type TimerFunc
- type TimerID
- type TimerType
- type TimerWheel
- func (w *TimerWheel) AddTimer(f TimerFunc, typ TimerType, period int64, arg interface{}) (*Timer, error)
- func (w *TimerWheel) After(d time.Duration) <-chan time.Time
- func (w *TimerWheel) AfterFunc(d time.Duration, f func()) *Timer
- func (w *TimerWheel) Close()
- func (w *TimerWheel) NewTicker(d time.Duration) *Ticker
- func (w *TimerWheel) NewTimer(d time.Duration) *Timer
- func (w *TimerWheel) Now() time.Time
- func (w *TimerWheel) Sleep(d time.Duration)
- func (w *TimerWheel) Stop()
- func (w *TimerWheel) Tick(d time.Duration) <-chan time.Time
- func (w *TimerWheel) TickFunc(d time.Duration, f func()) *Ticker
- func (w *TimerWheel) TimerNumber() int
- type Wheel
Examples ¶
Constants ¶
const ( ADD_TIMER timerAction = 1 DEL_TIMER timerAction = 2 RESET_TIMER timerAction = 3 )
Variables ¶
var ( ErrTimeChannelFull = fmt.Errorf("timer channel full") ErrTimeChannelClosed = fmt.Errorf("timer channel closed") )
var FirstDayMonday bool
var TimeFormats = []string{"1/2/2006", "1/2/2006 15:4:5", "2006-1-2 15:4:5", "2006-1-2 15:4", "2006-1-2", "1-2", "15:4:5", "15:4", "15", "15:4:5 Jan 2, 2006 MST", "2006-01-02 15:04:05.999999999 -0700 MST"}
Functions ¶
func BeginningOfDay ¶ added in v0.3.0
func BeginningOfHour ¶ added in v0.3.0
func BeginningOfMinute ¶ added in v0.3.0
func BeginningOfMonth ¶ added in v0.3.0
func BeginningOfQuarter ¶ added in v0.3.0
func BeginningOfWeek ¶ added in v0.3.0
func BeginningOfYear ¶ added in v0.3.0
func EndOfMinute ¶ added in v0.3.0
func EndOfMonth ¶ added in v0.3.0
func EndOfQuarter ¶ added in v0.3.0
func EndOfSunday ¶ added in v0.3.0
func Format ¶ added in v0.2.0
go implementation of strftime This is an alternative to time.Format because no one knows what date 040305 is supposed to create when used as a 'layout' string this takes standard strftime format options. For a complete list of format options see http://strftime.org/
Example ¶
t := time.Unix(1340244776, 0) utc, _ := time.LoadLocation("UTC") t = t.In(utc) fmt.Println(Format("%Y-%m-%d %H:%M:%S", t))
Output: 2012-06-21 02:12:56
func GetEndtime ¶ added in v0.3.2
func MustParseInLocation ¶ added in v0.3.0
func ParseInLocation ¶ added in v0.3.0
func Time2UnixNano ¶ added in v0.2.0
func TimeDayDuratioin ¶ added in v0.3.0
func TimeHourDuratioin ¶ added in v0.3.0
func TimeMicrosecondDuration ¶
func TimeMillisecondDuration ¶
func TimeMinuteDuration ¶ added in v0.3.0
func TimeNanosecondDuration ¶
func TimeSecondDuration ¶
func UnixNano2Time ¶ added in v0.2.0
func UnixString2Time ¶
Types ¶
type CountWatch ¶
type CountWatch struct {
// contains filtered or unexported fields
}
func (*CountWatch) Count ¶
func (w *CountWatch) Count() int64
func (*CountWatch) Reset ¶
func (w *CountWatch) Reset()
func (*CountWatch) Start ¶
func (w *CountWatch) Start()
type GxTime ¶ added in v0.3.0
parse time string
func (*GxTime) BeginningOfDay ¶ added in v0.3.0
func (*GxTime) BeginningOfHour ¶ added in v0.3.0
func (*GxTime) BeginningOfMinute ¶ added in v0.3.0
func (*GxTime) BeginningOfMonth ¶ added in v0.3.0
func (*GxTime) BeginningOfQuarter ¶ added in v0.3.0
func (*GxTime) BeginningOfWeek ¶ added in v0.3.0
func (*GxTime) BeginningOfYear ¶ added in v0.3.0
func (*GxTime) EndOfMinute ¶ added in v0.3.0
func (*GxTime) EndOfMonth ¶ added in v0.3.0
func (*GxTime) EndOfQuarter ¶ added in v0.3.0
func (*GxTime) EndOfSunday ¶ added in v0.3.0
type TimerWheel ¶ added in v0.2.0
type TimerWheel struct {
// contains filtered or unexported fields
}
timer based on multiple wheels
func NewTimerWheel ¶ added in v0.2.0
func NewTimerWheel() *TimerWheel
func (*TimerWheel) AddTimer ¶ added in v0.2.0
func (w *TimerWheel) AddTimer(f TimerFunc, typ TimerType, period int64, arg interface{}) (*Timer, error)
异步通知timerWheel添加一个timer,有可能失败
func (*TimerWheel) After ¶ added in v0.2.0
func (w *TimerWheel) After(d time.Duration) <-chan time.Time
func (*TimerWheel) AfterFunc ¶ added in v0.2.0
func (w *TimerWheel) AfterFunc(d time.Duration, f func()) *Timer
func (*TimerWheel) Close ¶ added in v0.2.0
func (w *TimerWheel) Close()
func (*TimerWheel) NewTicker ¶ added in v0.2.0
func (w *TimerWheel) NewTicker(d time.Duration) *Ticker
func (*TimerWheel) Now ¶ added in v0.3.0
func (w *TimerWheel) Now() time.Time
func (*TimerWheel) Sleep ¶ added in v0.2.0
func (w *TimerWheel) Sleep(d time.Duration)
func (*TimerWheel) Stop ¶ added in v0.2.0
func (w *TimerWheel) Stop()
func (*TimerWheel) Tick ¶ added in v0.2.0
func (w *TimerWheel) Tick(d time.Duration) <-chan time.Time
func (*TimerWheel) TickFunc ¶ added in v0.2.0
func (w *TimerWheel) TickFunc(d time.Duration, f func()) *Ticker
func (*TimerWheel) TimerNumber ¶ added in v0.2.0
func (w *TimerWheel) TimerNumber() int
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package gxtime encapsulates some golang.time functions refers from https://github.com/senseyeio/spaniel/blob/master/interval.go Package gxtime encapsulates some golang.time functions refer from https://github.com/senseyeio/spaniel/blob/master/timespan.go
|
Package gxtime encapsulates some golang.time functions refers from https://github.com/senseyeio/spaniel/blob/master/interval.go Package gxtime encapsulates some golang.time functions refer from https://github.com/senseyeio/spaniel/blob/master/timespan.go |