gotime

package
v1.0.130 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RFC3339Format       = time.RFC3339
	Iso8601Format       = "2006-01-02T15:04:05-07:00"
	CookieFormat        = "Monday, 02-Jan-2006 15:04:05 MST"
	RFC1036Format       = "Mon, 02 Jan 06 15:04:05 -0700"
	RFC7231Format       = "Mon, 02 Jan 2006 15:04:05 GMT"
	DayDateTimeFormat   = "Mon, Jan 2, 2006 3:04 PM"
	DateTimeFormat      = "2006-01-02 15:04:05"
	DateFormat          = "2006-01-02"
	TimeFormat          = "15:04:05"
	ShortDateTimeFormat = "20060102150405"
	ShortDateFormat     = "20060102"
	ShortTimeFormat     = "150405"
)

时间格式化常量

View Source
const (
	YearsPerMillennium = 1000 // 每千年1000年
	YearsPerCentury    = 100  // 每世纪100年
	YearsPerDecade     = 10   // 每十年10年
	QuartersPerYear    = 4    // 每年4季度
	MonthsPerYear      = 12   // 每年12月
	MonthsPerQuarter   = 3    // 每季度3月
	WeeksPerNormalYear = 52   // 每常规年52周

	WeeksPerMonth              = 4       // 每月4周
	DaysPerLeapYear            = 366     // 每闰年366天
	DaysPerNormalYear          = 365     // 每常规年365天
	DaysPerWeek                = 7       // 每周7天
	HoursPerWeek               = 168     // 每周168小时
	HoursPerDay                = 24      // 每天24小时
	MinutesPerDay              = 1440    // 每天1440分钟
	MinutesPerHour             = 60      // 每小时60分钟
	SecondsPerWeek             = 604800  // 每周604800秒
	SecondsPerDay              = 86400   // 每天86400秒
	SecondsPerHour             = 3600    // 每小时3600秒
	SecondsPerMinute           = 60      // 每分钟60秒
	MillisecondsPerSecond      = 1000    // 每秒1000毫秒
	MicrosecondsPerMillisecond = 1000    // 每毫秒1000微秒
	MicrosecondsPerSecond      = 1000000 // 每秒1000000微秒
)

数字常量

Variables

This section is empty.

Functions

func Verification added in v1.0.51

func Verification(str, layout string) (resp time.Time, err error)

Verification 验证字符串是否为时间

Types

type Pro

type Pro struct {
	Time time.Time

	Error error
	// contains filtered or unexported fields
}

Pro 结构体

func Current

func Current() Pro

Current 获取当前的时间

func NewPro

func NewPro() Pro

NewPro 初始化结构体

func SetCurrent

func SetCurrent(sTime time.Time) Pro

SetCurrent 设置当前的时间

func SetCurrentParse

func SetCurrentParse(str string) Pro

SetCurrentParse 设置当前的时间

func SetCurrentUnix added in v1.0.30

func SetCurrentUnix(ts int64) Pro

SetCurrentUnix 设置当前的时间 Unix时间戳

func Tomorrow added in v1.0.44

func Tomorrow() Pro

Tomorrow 明天

func Yesterday added in v1.0.44

func Yesterday() Pro

Yesterday 昨天

func (Pro) AfterDay

func (p Pro) AfterDay(day int) Pro

AfterDay 获取n天后的时间

func (Pro) AfterHour

func (p Pro) AfterHour(hour int64) Pro

AfterHour 获取n小时后的时间

func (Pro) AfterMinute added in v1.0.47

func (p Pro) AfterMinute(seconds int64) Pro

AfterMinute 获取n分钟后的时间

func (Pro) AfterSeconds

func (p Pro) AfterSeconds(seconds int64) Pro

AfterSeconds 获取n秒后的时间

func (Pro) BeforeDay

func (p Pro) BeforeDay(day int) Pro

BeforeDay 获取n天前的时间

func (Pro) BeforeHour

func (p Pro) BeforeHour(hour int64) Pro

BeforeHour 获取n小时前的时间

func (Pro) BeforeMinute added in v1.0.47

func (p Pro) BeforeMinute(seconds int64) Pro

BeforeMinute 获取n分钟前的时间

func (Pro) BeforeSeconds

func (p Pro) BeforeSeconds(seconds int64) Pro

BeforeSeconds 获取n秒前的时间

func (Pro) Between added in v1.0.47

func (p Pro) Between(start time.Time, end time.Time) bool

Between 是否在两个时间之间(不包括这两个时间)

func (Pro) BetweenIncludedBoth added in v1.0.47

func (p Pro) BetweenIncludedBoth(start time.Time, end time.Time) bool

BetweenIncludedBoth 是否在两个时间之间(包括这两个时间)

func (Pro) BetweenIncludedEnd added in v1.0.47

func (p Pro) BetweenIncludedEnd(start time.Time, end time.Time) bool

BetweenIncludedEnd 是否在两个时间之间(包括结束时间)

func (Pro) BetweenIncludedStart added in v1.0.47

func (p Pro) BetweenIncludedStart(start time.Time, end time.Time) bool

BetweenIncludedStart 是否在两个时间之间(包括开始时间)

func (Pro) Bson added in v1.0.47

func (p Pro) Bson() string

Bson mongoDB

func (Pro) DiffInHour

func (p Pro) DiffInHour(t2 time.Time) (hour int64)

DiffInHour 相差多少小时

func (Pro) DiffInHourWithAbs

func (p Pro) DiffInHourWithAbs(t2 time.Time) (hour int64)

DiffInHourWithAbs 相差多少小时(绝对值)

func (Pro) DiffInMinutes

func (p Pro) DiffInMinutes(t2 time.Time) (hour int64)

DiffInMinutes 相差多少分钟

func (Pro) DiffInMinutesWithAbs

func (p Pro) DiffInMinutesWithAbs(t2 time.Time) (hour int64)

DiffInMinutesWithAbs 相差多少分钟(绝对值)

func (Pro) DiffInSecond

func (p Pro) DiffInSecond(t2 time.Time) (hour int64)

DiffInSecond 相差多少秒

func (Pro) DiffInSecondWithAbs

func (p Pro) DiffInSecondWithAbs(t2 time.Time) (hour int64)

DiffInSecondWithAbs 相差多少秒(绝对值)

func (Pro) EndOfCentury added in v1.0.44

func (p Pro) EndOfCentury() Pro

EndOfCentury 本世纪结束时间

func (Pro) EndOfDay

func (p Pro) EndOfDay() Pro

EndOfDay 本日结束时间

func (Pro) EndOfDecade added in v1.0.44

func (p Pro) EndOfDecade() Pro

EndOfDecade 本年代结束时间

func (Pro) EndOfMonth added in v1.0.44

func (p Pro) EndOfMonth() Pro

EndOfMonth 本月结束时间

func (Pro) EndOfQuarter added in v1.0.44

func (p Pro) EndOfQuarter() Pro

EndOfQuarter 本季度结束时间

func (Pro) EndOfYear added in v1.0.44

func (p Pro) EndOfYear() Pro

EndOfYear 本年结束时间

func (Pro) Eq added in v1.0.47

func (p Pro) Eq(t2 time.Time) bool

Eq 是否等于

func (Pro) Format

func (p Pro) Format() string

Format 今天此刻格式化

func (Pro) Gt added in v1.0.47

func (p Pro) Gt(t2 time.Time) bool

Gt 是否大于

func (Pro) Gte added in v1.0.47

func (p Pro) Gte(t2 time.Time) bool

Gte 是否大于等于

func (Pro) Lt added in v1.0.47

func (p Pro) Lt(t2 time.Time) bool

Lt 是否小于

func (Pro) Lte added in v1.0.47

func (p Pro) Lte(t2 time.Time) bool

Lte 是否小于等于

func (Pro) Month added in v1.0.44

func (p Pro) Month() int64

Month 获取当前月

func (Pro) MonthOfYear added in v1.0.44

func (p Pro) MonthOfYear() int64

MonthOfYear 获取本年的第几月

func (Pro) Ne added in v1.0.47

func (p Pro) Ne(t2 time.Time) bool

Ne 是否不等于

func (Pro) Now

func (p Pro) Now() time.Time

Now 今天此刻

func (Pro) Quarter added in v1.0.44

func (p Pro) Quarter() (quarter int)

Quarter 获取当前季度

func (Pro) SetFormat

func (p Pro) SetFormat(layout string) string

SetFormat 格式化

func (Pro) StartOfCentury added in v1.0.44

func (p Pro) StartOfCentury() Pro

StartOfCentury 本世纪开始时间

func (Pro) StartOfDay

func (p Pro) StartOfDay() Pro

StartOfDay 本日开始时间

func (Pro) StartOfDecade added in v1.0.44

func (p Pro) StartOfDecade() Pro

StartOfDecade 本年代开始时间

func (Pro) StartOfMonth added in v1.0.44

func (p Pro) StartOfMonth() Pro

StartOfMonth 本月开始时间

func (Pro) StartOfQuarter added in v1.0.44

func (p Pro) StartOfQuarter() Pro

StartOfQuarter 本季度开始时间

func (Pro) StartOfYear added in v1.0.44

func (p Pro) StartOfYear() Pro

StartOfYear 本年开始时间

func (Pro) Timestamp

func (p Pro) Timestamp() int64

Timestamp 今天此刻时间戳

func (Pro) TimestampWithMicrosecond added in v1.0.44

func (p Pro) TimestampWithMicrosecond() int64

TimestampWithMicrosecond 今天微秒级时间戳

func (Pro) TimestampWithMillisecond

func (p Pro) TimestampWithMillisecond() int64

TimestampWithMillisecond 今天毫秒级时间戳

func (Pro) TimestampWithNanosecond added in v1.0.44

func (p Pro) TimestampWithNanosecond() int64

TimestampWithNanosecond 今天纳秒级时间戳

func (Pro) TimestampWithSecond added in v1.0.44

func (p Pro) TimestampWithSecond() int64

TimestampWithSecond 今天此刻时间戳

func (Pro) ToDateFormat added in v1.0.44

func (p Pro) ToDateFormat() string

ToDateFormat 今天此刻日期

func (Pro) ToTimeFormat added in v1.0.44

func (p Pro) ToTimeFormat() string

ToTimeFormat 今天此刻时间

Jump to

Keyboard shortcuts

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