time

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Precision = time.Microsecond

Precision 确定此库对时间的精确度. 序列化和反序列化令牌时,时间值会自动截断至此精度. 有关更多详细信息,请参见时间包的Truncate方法。

Variables

View Source
var TimeFunc = time.Now

Functions

func At

func At(at time.Time) time.Time

At 根据标准库时间生成时间值。

func Date

func Date(ti int64, format string) string

Date 将unix时间整型格式化为字符串

func DateParse

func DateParse(dateString, format string) (time.Time, error)

DateParse 解析日期使用PHP时间格式.

func DateS

func DateS(ts string, format string) string

DateS 将unix时间字符串格式化为字符串

func DateT

func DateT(t time.Time, format string) string

DateT 将time.Time结构格式化为字符串 MM - month - 01 M - month - 1, single bit DD - day - 02 D - day 2 YYYY - year - 2006 YY - year - 06 HH - 24 hours - 03 H - 24 hours - 3 hh - 12 hours - 03 h - 12 hours - 3 mm - minute - 04 m - minute - 4 ss - second - 05 s - second = 5

func NewTime

func NewTime(t float64) time.Time

NewTime 从float64创建一个新的时间值

func Now

func Now() time.Time

Now 使用当前时间返回新的时间值. 您可以通过更改TimeFunc的值来覆盖Now。

Types

type Duration

type Duration time.Duration

Duration 用于取消编组字符串时间,例如1s,500ms.

func NewDuration

func NewDuration(str string) (dur Duration)

func (Duration) Shrink

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText 将文本解组到持续时间.

type NumberTime

type NumberTime time.Time

func (NumberTime) MarshalJSON

func (nt NumberTime) MarshalJSON() ([]byte, error)

func (*NumberTime) UnmarshalJSON

func (nt *NumberTime) UnmarshalJSON(data []byte) error

type StringTime

type StringTime time.Time

func (StringTime) MarshalJSON

func (st StringTime) MarshalJSON() ([]byte, error)

MarshalJSON 实现它的json序列化方法

func (*StringTime) UnmarshalJSON

func (st *StringTime) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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