datetime

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateFormat      = "2006-01-02 15:04:05"
	TimestampFormat = "2006-01-02 15:04:05.999"
)
View Source
const (
	DefaultTickInterval = 250 * time.Millisecond // 1秒tick4次
)

Variables

View Source
var (
	DummyTime     time.Time
	DateFormatSep = "-"
	TimeFormatSep = ":"
	DateTimeSep   = " "
)

Functions

func DaysCountOfMonth

func DaysCountOfMonth(year, month int) int

一个月的天数

func FormatTime

func FormatTime(t time.Time) string

func IsLeapYear

func IsLeapYear(year int) bool

是否闰年

func MustParseDateTime

func MustParseDateTime(s string) time.Time

func MustParseMomentDate

func MustParseMomentDate(tm time.Time, s string) time.Time

func MustParseMomentTime

func MustParseMomentTime(tm time.Time, s string) time.Time

func MustParseTime

func MustParseTime(s string) time.Time

解析时间字符串

func ParseDateParts

func ParseDateParts(s string, seg []int) error

解析年月日格式,如:2001-3-4, 12-4

func ParseDateTime

func ParseDateTime(s string) (time.Time, error)

解析时间字符串 [2001-5-7 12:34:56]

func ParseMomentDate

func ParseMomentDate(tm time.Time, dateText string) (time.Time, error)

根据当前时间和字符串日期,生成一个新的time.Time对象

func ParseMomentTime

func ParseMomentTime(tm time.Time, timeText string) (time.Time, error)

根据当前时间和字符串日期,生成一个新的time.Time对象

func ParseTimeParts

func ParseTimeParts(s string, seg []int) error

解析时分秒格式,如:12:34:56

Types

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

Clock提供一些对壁钟时间的操作,不适用于高精度的计时场景 设计初衷是为精度至少为秒的上层业务服务, 支持时钟的往前/后调拨

func NewClock

func NewClock(interval time.Duration) *Clock

func (*Clock) DateTime

func (c *Clock) DateTime() string

func (*Clock) Go

func (c *Clock) Go()

func (*Clock) Now

func (c *Clock) Now() time.Time

func (*Clock) Reset

func (c *Clock) Reset()

恢复时钟

func (*Clock) Stop

func (c *Clock) Stop()

func (*Clock) TickCount

func (c *Clock) TickCount() int64

func (*Clock) Travel

func (c *Clock) Travel(d time.Duration)

时间旅行(拨动时钟)

Jump to

Keyboard shortcuts

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