xtime

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DurationToUnit

func DurationToUnit(duration time.Duration) string

func FormatDate

func FormatDate(dateStr string) (formatDate string)

格式化Date成字符串

格式化前输入样式:2019-01-04T15:40:00Z 或 2019-01-04T15:40:00+08:00
格式化后返回样式:2019-01-04

func FormatDateTime

func FormatDateTime(timeStr string) (formatTime string)

格式化Datetime字符串

格式化前输入样式:2019-01-04T15:40:00Z 或 2019-01-04T15:40:00+08:00
格式化后返回样式:2019-01-04 15:40:00

func ParseDate

func ParseDate(timeStr string) (date time.Time)

解析日期

日期字符串格式:2006-01-02

func ParseDateTime

func ParseDateTime(timeStr string) (datetime time.Time)

解析时间

时间字符串格式:2006-01-02 15:04:05

Types

type Duration

type Duration time.Duration

Duration be used json unmarshal string time, like 1s, 500ms.

func (Duration) Shrink

Shrink will decrease the duration by comparing with context's timeout duration and return new timeout\context\CancelFunc.

func (*Duration) UnitTime

func (d *Duration) UnitTime() string

UnitTime duration parse to unit, such as "300ms", "1h30m" or "2h10s".

func (*Duration) UnmarshalText

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

UnmarshalText unmarshal text to duration.

type Time

type Time int64

Time be used to MySql timestamp converting.

func (*Time) FromDB

func (t *Time) FromDB(bs []byte) error

func (*Time) Scan

func (t *Time) Scan(src interface{}) (err error)

Scan scan time.

func (Time) Time

func (t Time) Time() time.Time

Time get time.

func (Time) ToDB

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

func (Time) Value

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

Value get time value.

Jump to

Keyboard shortcuts

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