dateTime

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Since added in v0.10.0

func Since(dt DateTime) time.Duration

Since time.Now().Sub(dt).

Types

type DateTime

type DateTime struct {
	// contains filtered or unexported fields
}

func New

func New(time time.Time) DateTime

New 初始化

func NewUnix added in v0.10.0

func NewUnix(sec int64) DateTime

NewUnix 初始化

func NewUnixMicro added in v0.12.0

func NewUnixMicro(usec int64) DateTime

NewUnixMicro 初始化

func NewUnixMilli added in v0.10.0

func NewUnixMilli(msec int64) DateTime

NewUnixMilli 初始化

func Now

func Now() DateTime

Now 当前时间

func Parse added in v0.13.0

func Parse(layout, value string) (DateTime, error)

func (DateTime) AddDate

func (receiver DateTime) AddDate(years int, months int, days int) DateTime

AddDate 添加Date

func (DateTime) AddDays

func (receiver DateTime) AddDays(days int) DateTime

AddDays 添加天数

func (DateTime) AddHours

func (receiver DateTime) AddHours(hours int) DateTime

AddHours 添加小时

func (DateTime) AddMillisecond added in v0.10.0

func (receiver DateTime) AddMillisecond(millisecond int) DateTime

AddMillisecond 添加毫秒

func (DateTime) AddMinutes

func (receiver DateTime) AddMinutes(minutes int) DateTime

AddMinutes 添加分钟

func (DateTime) AddMonths

func (receiver DateTime) AddMonths(months int) DateTime

AddMonths 添加月份

func (DateTime) AddSeconds

func (receiver DateTime) AddSeconds(seconds int) DateTime

AddSeconds 添加秒

func (DateTime) AddTime

func (receiver DateTime) AddTime(hours int, minutes int, seconds int) DateTime

AddTime 添加Time

func (DateTime) AddYears

func (receiver DateTime) AddYears(year int) DateTime

AddYears 添加年

func (DateTime) After added in v0.10.0

func (receiver DateTime) After(dt DateTime) bool

After 是否比dt时间大(晚)

func (DateTime) Before added in v0.11.0

func (receiver DateTime) Before(dt DateTime) bool

Before 是否比dt时间小(早)

func (DateTime) Date

func (receiver DateTime) Date() DateTime

Date 获取Date部份

func (DateTime) Day

func (receiver DateTime) Day() int

Day 获取日

func (DateTime) Duration added in v0.9.0

func (receiver DateTime) Duration() time.Duration

Duration 得到Duration

func (DateTime) Hour

func (receiver DateTime) Hour() int

Hour 获取小时

func (DateTime) MarshalJSON added in v0.8.0

func (receiver DateTime) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte 此处不能用指针,否则json序列化时不执行

func (DateTime) Minute

func (receiver DateTime) Minute() int

Minute 获取分钟

func (DateTime) Month

func (receiver DateTime) Month() int

Month 获取月

func (DateTime) ResetDay added in v0.14.0

func (receiver DateTime) ResetDay() DateTime

ResetDay 抹除天数,将天、小时、分、秒、毫秒 设为0

func (*DateTime) Scan added in v0.10.0

func (receiver *DateTime) Scan(val any) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (DateTime) Second

func (receiver DateTime) Second() int

Second 获取秒

func (DateTime) Sub added in v0.10.0

func (receiver DateTime) Sub(dt DateTime) time.Duration

Sub 时间相减

func (DateTime) ToString

func (receiver DateTime) ToString(format string) string

ToString 转字符串,yyyy-MM-dd hh:mm:ss

func (DateTime) ToTime

func (receiver DateTime) ToTime() time.Time

ToTime 获取time.Time类型

func (DateTime) UnixMicro added in v0.6.0

func (receiver DateTime) UnixMicro() int64

UnixMicro 获取微秒

func (DateTime) UnixMilli added in v0.6.0

func (receiver DateTime) UnixMilli() int64

UnixMilli 获取毫秒

func (DateTime) UnixNano added in v0.6.0

func (receiver DateTime) UnixNano() int64

UnixNano 获取纳秒

func (*DateTime) UnmarshalJSON added in v0.8.0

func (receiver *DateTime) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (DateTime) Value added in v0.10.0

func (receiver DateTime) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

func (DateTime) Year

func (receiver DateTime) Year() int

Year 获取年

Jump to

Keyboard shortcuts

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