timex

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const N = int(unsafe.Sizeof(0))

Variables

View Source
var CustomizeHourLayout = "15:04:05"
View Source
var DetectorLayout = "20060102 15:04:05"
View Source
var Layout = "2006-01-02 15:04:05"
View Source
var LayoutBt = "2006-01-02T15:04:05"
View Source
var Loc, _ = time.LoadLocation("Local")
View Source
var SimplifyLayout = "2006-01-02"

Functions

func DateStrFormat

func DateStrFormat(dateStr string) string

func DateStrParse

func DateStrParse(dateStr string) time.Time

func DateStrParses

func DateStrParses(year string, month string, day string) time.Time

func FormatSeconds

func FormatSeconds(value int) (hour, middle, seconds int)

FormatSeconds 格式化秒数为时、分、秒

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

GetFirstDateOfMonth 获取传入的时间所在月份的第一天, 即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetLastDateOfMonth

func GetLastDateOfMonth(d time.Time) time.Time

GetLastDateOfMonth 获取传入的时间所在月份的最后一天, 即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。

func GetMonthOfTheDayStrs

func GetMonthOfTheDayStrs(d time.Time) (dayStrs []string)

GetMonthOfTheDayStrs 获取某一天所在月所有的天

func GetWeekByDate

func GetWeekByDate(d time.Time) (week int)

GetWeekByDate 获取传入时间所在一年当中的第几周(1-52)

func GetWeekStart

func GetWeekStart(d time.Time) time.Time

GetWeekStart 获取传入时间所在周的开始时间(星期一)

func GetZeroTime

func GetZeroTime(d time.Time) time.Time

GetZeroTime 获取某一天的0点时间

func TimeSubDay

func TimeSubDay(beginTimeIf interface{}, endTimeIf interface{}) int

TimeSubDay 获取两个时间相差的天数

Types

type Date

type Date struct {
	time.Time
}

func ParseDate

func ParseDate(time string) Date

func (Date) MarshalJSON

func (t Date) MarshalJSON() ([]byte, error)

MarshalJSON on JSONTime format Time field with %Y-%m-%d

func (*Date) Scan

func (t *Date) Scan(v interface{}) error

Scan valueof time.Time

func (Date) UnmarshalJSON

func (t Date) UnmarshalJSON(data []byte) error

func (Date) Value

func (t Date) Value() (driver.Value, error)

Value insert timestamp into mysql need this function.

type Time

type Time struct {
	time.Time
}

Time format json timex field by myself

func Now

func Now() Time

func ParseTime

func ParseTime(time string) Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON on JSONTime format Time field with %Y-%m-%d %H:%M:%S

func (*Time) Scan

func (t *Time) Scan(v interface{}) error

Scan valueof time.Time

func (Time) UnmarshalJSON

func (t Time) UnmarshalJSON(data []byte) error

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value insert timestamp into mysql need this function.

Jump to

Keyboard shortcuts

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