datetime

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 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 = 400 // 400毫秒tick一次
)

Variables

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

Functions

func CurrentTimeMillis

func CurrentTimeMillis() int64

当前unix毫秒时间戳

func DaysCountOfMonth

func DaysCountOfMonth(year, month int) int

一个月的天数

func ElapsedDaysBetween

func ElapsedDaysBetween(start, end time.Time) int

获取两个时间中经过的天数

func EndOfWeek

func EndOfWeek(t time.Time) time.Time

本周的最后一天

func FirstDayOfYear

func FirstDayOfYear(year int) time.Time

年度第一天

func FormatTime

func FormatTime(t time.Time) string

格式化字符串

func FormatUnixTime

func FormatUnixTime(v int64) string

格式化时间字符串

func IsLeapYear

func IsLeapYear(year int) bool

是否闰年

func LastDayOfYear

func LastDayOfYear(year int) time.Time

年度最后一天

func MidnightTimeOf

func MidnightTimeOf(t time.Time) time.Time

当日零点

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

func StartingOfWeek

func StartingOfWeek(t time.Time) time.Time

本周的起点

func ThisMomentAfterDays

func ThisMomentAfterDays(this time.Time, days int) time.Time

N天后的这个时候

func TimeToMillis

func TimeToMillis(t time.Time) int64

转换unix毫秒时间戳

Types

type Clock

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

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

func NewClock

func NewClock(interval int) *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