timelib

package
v0.0.0-...-61829c1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	WORKING_DAYS = 5
	WEEKEND_DAYS = 2
	DAY_SECONDS  = 86400
)
View Source
const (
	CST_ZONE_OFFSET = 8 * 60 * 60
)

Variables

View Source
var (
	MySQLTimestampZero     = MySQLTimestamp(time.Time{})
	MySQLTimestampUnixZero = MySQLTimestamp(time.Unix(0, 0))
)
View Source
var (
	UTC *time.Location
	CST *time.Location
)
View Source
var (
	MySQLDatetimeZero = MySQLDatetime(time.Time{})
)

Functions

func AddWorkingDaysInLocation

func AddWorkingDaysInLocation(t time.Time, days int, loc *time.Location) time.Time

根据指定时区添加 N 个工作日

func CountDateDiff

func CountDateDiff(startTime, endTime time.Time, loc *time.Location) int64

计算日期偏差

func GetTodayFirstSecInLocation

func GetTodayFirstSecInLocation(t time.Time, loc *time.Location) time.Time

根据指定时区获取当天第一秒

func GetTodayLastSecInLocation

func GetTodayLastSecInLocation(t time.Time, loc *time.Location) time.Time

根据指定时区获取当天最后一秒

func Now

func Now() time.Time

Types

type MySQLDatetime

type MySQLDatetime time.Time

swagger:strfmt date-time

func ParseMySQLDatetimeFromString

func ParseMySQLDatetimeFromString(s string) (dt MySQLDatetime, err error)

func ParseMySQLDatetimeFromStringWithFormatterInCST

func ParseMySQLDatetimeFromStringWithFormatterInCST(s, formatter string) (dt MySQLDatetime, err error)

func (MySQLDatetime) AddWorkingDaysCST

func (dt MySQLDatetime) AddWorkingDaysCST(days int) MySQLDatetime

添加N个工作日(东8区)

func (MySQLDatetime) Format

func (dt MySQLDatetime) Format(layout string) string

func (MySQLDatetime) GetTodayFirstSecCST

func (dt MySQLDatetime) GetTodayFirstSecCST() MySQLDatetime

获取当天0点(东8区)

func (MySQLDatetime) GetTodayLastSecCST

func (dt MySQLDatetime) GetTodayLastSecCST() MySQLDatetime

获取当天最后一秒(东8区)

func (MySQLDatetime) In

func (MySQLDatetime) IsZero

func (dt MySQLDatetime) IsZero() bool

func (MySQLDatetime) MarshalText

func (dt MySQLDatetime) MarshalText() ([]byte, error)

func (*MySQLDatetime) Scan

func (dt *MySQLDatetime) Scan(value interface{}) error

func (MySQLDatetime) String

func (dt MySQLDatetime) String() string

func (MySQLDatetime) Unix

func (dt MySQLDatetime) Unix() int64

func (*MySQLDatetime) UnmarshalText

func (dt *MySQLDatetime) UnmarshalText(data []byte) (err error)

func (MySQLDatetime) Value

func (dt MySQLDatetime) Value() (driver.Value, error)

type MySQLTimestamp

type MySQLTimestamp time.Time

swagger:strfmt date-time

func ParseMySQLTimestampFromString

func ParseMySQLTimestampFromString(s string) (dt MySQLTimestamp, err error)

func (MySQLTimestamp) AddWorkingDaysCST

func (dt MySQLTimestamp) AddWorkingDaysCST(days int) MySQLTimestamp

添加 N 个工作日(东8区)

func (MySQLTimestamp) Format

func (dt MySQLTimestamp) Format(layout string) string

func (MySQLTimestamp) GetTodayFirstSecCST

func (dt MySQLTimestamp) GetTodayFirstSecCST() MySQLTimestamp

获取当天0点(东8区)

func (MySQLTimestamp) GetTodayLastSecCST

func (dt MySQLTimestamp) GetTodayLastSecCST() MySQLTimestamp

获取当天最后一秒(东8区)

func (MySQLTimestamp) In

func (MySQLTimestamp) IsZero

func (dt MySQLTimestamp) IsZero() bool

func (MySQLTimestamp) MarshalText

func (dt MySQLTimestamp) MarshalText() ([]byte, error)

func (*MySQLTimestamp) Scan

func (dt *MySQLTimestamp) Scan(value interface{}) error

func (MySQLTimestamp) String

func (dt MySQLTimestamp) String() string

func (MySQLTimestamp) Unix

func (dt MySQLTimestamp) Unix() int64

func (*MySQLTimestamp) UnmarshalText

func (dt *MySQLTimestamp) UnmarshalText(data []byte) (err error)

func (MySQLTimestamp) Value

func (dt MySQLTimestamp) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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