xtime

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeLayout   = "2006-01-02 15:04:05"
	TimeLayout_1 = "2006-01-02 15:04:05.000"
	TimeLayout_2 = "20060102150405"
	DateLayout   = "2006-01-02"
)

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 GetCurMonthDays

func GetCurMonthDays() (curMonthDays []string)

获取本月 日期

func GetCurWeekDays

func GetCurWeekDays() (curWeekDays []string)

获取本周 7天 日期

func GetLastMonthDays

func GetLastMonthDays() (monthDays []string)

获取上一个月 日期

func GetRecentSevenDay

func GetRecentSevenDay() (sevenDays []string)

获取最近 7天 日期

func GetRecentThirtyDay

func GetRecentThirtyDay() (thirtyDays []string)

获取最近 30天 日期

func MonthDays

func MonthDays(m time.Month, year int) int

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