extime

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeLayout           = "2006-01-02 15:04:05"
	TimeNopLayout        = "20060102150405"
	DateLayout           = "2006-01-02"
	DateSlashLayout      = "2006/01/02"
	DateDotLayout        = "2006.01.02"
	DateNopLayout        = "20060102"
	DateMonthLayout      = "2006-01"
	DateMonthSlashLayout = "2006/01"
	DateMonthDotLayout   = "2006.01"
	DateMonthNopLayout   = "200601"
)

Variables

This section is empty.

Functions

func Days

func Days(d time.Duration) float64

Days time.Duration转化为天数

func EndOfDay

func EndOfDay(t time.Time) time.Time

EndOfDay 获取时间中当天的结束时间. 2022-02-18 23:59:59.999999999 +0800 CST

func EndOfMonth

func EndOfMonth(t time.Time) time.Time

EndOfMonth 获取时间中当月的结束时间. 2022-02-28 23:59:59.999999999 +0800 CST

func EndOfQuarter added in v0.1.0

func EndOfQuarter(year int, q Quarter) time.Time

EndOfQuarter 获取季度结束的时间 2022-03-31 23:59:59.999999999 +0800 CST

func EndOfQuarter2 added in v0.1.0

func EndOfQuarter2(t time.Time) time.Time

EndOfQuarter 获取时间的季度结束的时间 2022-03-31 23:59:59.999999999 +0800 CST

func EndOfWeek

func EndOfWeek(date time.Time, weekStartDay ...time.Weekday) time.Time

EndOfWeek 获取时间当周的结束时间; weekStartDay 周几作为周的第一天,本库默认周一.

func EndOfYear

func EndOfYear(t time.Time) time.Time

EndOfYear 获取时间当年的结束时间. 2022-12-31 23:59:59.999999999 +0800 CST

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear 是否闰年

func MonthDays

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

MonthDays 所在年份月份的天数

func MonthDays2

func MonthDays2(t time.Time) int

MonthDays2 t 所在时间月份的天数

func NexEndOfMonth added in v0.1.0

func NexEndOfMonth(t time.Time) time.Time

NexEndOfMonth 获取时间中下月的结束时间. 2022-03-31 23:59:59.999999999 +0800 CST

func NextEndOfDay added in v0.1.0

func NextEndOfDay(t time.Time) time.Time

NextEndOfDay 获取时间中下一天的结束时间. 2022-02-19 23:59:59.999999999 +0800 CST

func NextEndOfQuarter added in v0.1.0

func NextEndOfQuarter(year int, q Quarter) time.Time

NextEndOfQuarter 获取下一季度结束的时间 2022-06-31 23:59:59.999999999 +0800 CST

func NextEndOfQuarter2 added in v0.1.0

func NextEndOfQuarter2(t time.Time) time.Time

NextEndOfQuarter 获取时间的下一季度结束的时间 2022-06-31 23:59:59.999999999 +0800 CST

func NextEndOfWeek added in v0.1.0

func NextEndOfWeek(date time.Time, weekStartDay ...time.Weekday) time.Time

NextEndOfWeek 获取时间当周的结束时间; weekStartDay 周几作为周的第一天,本库默认周一.

func NextEndOfYear added in v0.1.0

func NextEndOfYear(t time.Time) time.Time

NextEndOfYear 获取日期中下一年的结束时间. 2023-12-31 23:59:59.999999999 +0800 CST

func NextStartOfDay added in v0.1.0

func NextStartOfDay(t time.Time) time.Time

NextStartOfDay 获取时间中下一天的开始时间. 2022-02-19 00:00:00 +0800 CST

func NextStartOfMonth added in v0.1.0

func NextStartOfMonth(t time.Time) time.Time

NextStartOfMonth 获取时间中下月的开始时间. 2022-03-01 00:00:00 +0800 CST

func NextStartOfQuarter added in v0.1.0

func NextStartOfQuarter(year int, q Quarter) time.Time

NextStartOfQuarter 获取下个季度开始的时间 2022-04-01 00:00:00 +0800 CST

func NextStartOfQuarter2 added in v0.1.0

func NextStartOfQuarter2(t time.Time) time.Time

NextStartOfQuarter 获取时间的下个季度开始的时间 2022-04-01 00:00:00 +0800 CST

func NextStartOfWeek added in v0.1.0

func NextStartOfWeek(date time.Time, weekStartDay ...time.Weekday) time.Time

NextStartOfWeek 获取时间下一周的开始时间; weekStartDay 周几作为周的第一天,本库默认周一.

func NextStartOfYear added in v0.1.0

func NextStartOfYear(t time.Time) time.Time

NextStartOfYear 获取时间下一年的开始时间. 2023-01-01 00:00:00 +0800 CST

func PreviousEndOfDay added in v0.1.0

func PreviousEndOfDay(t time.Time) time.Time

PreviousEndOfDay 获取时间中前一天的结束时间. 2022-02-17 23:59:59.999999999 +0800 CST

func PreviousEndOfMonth added in v0.1.0

func PreviousEndOfMonth(t time.Time) time.Time

PreviousEndOfMonth 获取时间中上月的结束时间. 2022-01-31 23:59:59.999999999 +0800 CST

func PreviousEndOfQuarter added in v0.1.0

func PreviousEndOfQuarter(year int, q Quarter) time.Time

PreviousEndOfQuarter 获取上一季度结束的时间 2022-12-31 23:59:59.999999999 +0800 CST

func PreviousEndOfQuarter2 added in v0.1.0

func PreviousEndOfQuarter2(t time.Time) time.Time

PreviousEndOfQuarter 获取时间的上一季度结束的时间 2022-12-31 23:59:59.999999999 +0800 CST

func PreviousEndOfWeek added in v0.1.0

func PreviousEndOfWeek(date time.Time, weekStartDay ...time.Weekday) time.Time

PreviousEndOfWeek 获取时间上周的结束时间; weekStartDay 周几作为周的第一天,本库默认周一.

func PreviousEndOfYear added in v0.1.0

func PreviousEndOfYear(t time.Time) time.Time

PreviousEndOfYear 获取时间上一年的结束时间. 2021-12-31 23:59:59.999999999 +0800 CST

func PreviousStartOfDay added in v0.1.0

func PreviousStartOfDay(t time.Time) time.Time

PreviousStartOfDay 获取时间中上一天的开始时间. 2022-02-17 00:00:00 +0800 CST

func PreviousStartOfMonth added in v0.1.0

func PreviousStartOfMonth(t time.Time) time.Time

PreviousStartOfMonth 获取时间中上月的开始时间. 2022-01-01 00:00:00 +0800 CST

func PreviousStartOfQuarter added in v0.1.0

func PreviousStartOfQuarter(year int, q Quarter) time.Time

PreviousStartOfQuarter 获取上个季度开始的时间 2022-01-01 00:00:00 +0800 CST

func PreviousStartOfQuarter2 added in v0.1.0

func PreviousStartOfQuarter2(t time.Time) time.Time

PreviousStartOfQuarter 获取时间的上个季度开始的时间 2022-01-01 00:00:00 +0800 CST

func PreviousStartOfWeek added in v0.1.0

func PreviousStartOfWeek(date time.Time, weekStartDay ...time.Weekday) time.Time

PreviousStartOfWeek 获取时间中上一周的开始时间; weekStartDay 周几作为周的第一天,本库默认周一.

func PreviousStartOfYear added in v0.1.0

func PreviousStartOfYear(t time.Time) time.Time

PreviousStartOfYear 获取时间上一年的开始时间. 2023-01-01 00:00:00 +0800 CST

func StartOfDay

func StartOfDay(t time.Time) time.Time

StartOfDay 获取时间中当天的开始时间. 2022-02-18 00:00:00 +0800 CST

func StartOfMonth

func StartOfMonth(t time.Time) time.Time

StartOfMonth 获取时间中当月的开始时间. 2022-02-01 00:00:00 +0800 CST

func StartOfQuarter added in v0.1.0

func StartOfQuarter(year int, q Quarter) time.Time

StartOfQuarter 获取季度开始的时间 q的值不为范围内的值, 返回第一季度值 2022-01-01 00:00:00 +0800 CST

func StartOfQuarter2 added in v0.1.0

func StartOfQuarter2(t time.Time) time.Time

StartOfQuarter2 获取时间季度开始的时间 2022-01-01 00:00:00 +0800 CST

func StartOfWeek

func StartOfWeek(date time.Time, weekStartDay ...time.Weekday) time.Time

StartOfWeek 获取时间当周的开始时间; weekStartDay 周几作为周的第一天,本库默认周一.

func StartOfYear

func StartOfYear(t time.Time) time.Time

StartOfYear 获取时间当年的开始时间. 2022-01-01 00:00:00 +0800 CST

func Valid

func Valid(year, month, day int) bool

Valid 检查是否正常的日期. 1<= year <= 9999 1<= month < 12 1<= day <=31 && day <= monthDays(month)

func ValidMonth added in v0.1.0

func ValidMonth(month int) bool

ValidMonth 检查是否正常的月.

func ValidQuarter added in v0.1.0

func ValidQuarter(q int) bool

ValidQuarter 是否为有效的季度

func ValidYear added in v0.1.0

func ValidYear(year int) bool

ValidYear 检查是否正常的年.

func YearDays

func YearDays(year int) int

YearDays 所在年份总天数

Types

type Date

type Date time.Time

Date 格式: 2006-01-02

func ToDate added in v0.1.0

func ToDate(t time.Time) Date

ToDate time.Time to Date

func (Date) MarshalJSON added in v0.1.0

func (t Date) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (Date) MarshalText added in v0.1.0

func (t Date) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (Date) StdTime added in v0.1.0

func (t Date) StdTime() time.Time

StdTime convert to standard time

func (Date) String added in v0.1.0

func (t Date) String() string

String implemented interface Stringer

func (*Date) UnmarshalJSON added in v0.1.0

func (t *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*Date) UnmarshalText added in v0.1.0

func (t *Date) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type DateDot added in v0.1.0

type DateDot time.Time

DateDot 格式: 2006.01.02

func ToDateDot added in v0.1.0

func ToDateDot(t time.Time) DateDot

ToDateDot time.Time to DateDot

func (DateDot) MarshalJSON added in v0.1.0

func (t DateDot) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (DateDot) MarshalText added in v0.1.0

func (t DateDot) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (DateDot) StdTime added in v0.1.0

func (t DateDot) StdTime() time.Time

StdTime convert to standard time

func (DateDot) String added in v0.1.0

func (t DateDot) String() string

String implemented interface Stringer

func (*DateDot) UnmarshalJSON added in v0.1.0

func (t *DateDot) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*DateDot) UnmarshalText added in v0.1.0

func (t *DateDot) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type DateMonth added in v0.1.0

type DateMonth time.Time

DateMonth 格式: 2006-01

func ToDateMonth added in v0.1.0

func ToDateMonth(t time.Time) DateMonth

ToDateMonth time.Time to DateMonth

func (DateMonth) MarshalJSON added in v0.1.0

func (t DateMonth) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (DateMonth) MarshalText added in v0.1.0

func (t DateMonth) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (DateMonth) StdTime added in v0.1.0

func (t DateMonth) StdTime() time.Time

StdTime convert to standard time

func (DateMonth) String added in v0.1.0

func (t DateMonth) String() string

String implemented interface Stringer

func (*DateMonth) UnmarshalJSON added in v0.1.0

func (t *DateMonth) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*DateMonth) UnmarshalText added in v0.1.0

func (t *DateMonth) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type DateMonthDot added in v0.1.0

type DateMonthDot time.Time

DateMonthSlash 格式: 2006.01

func ToDateMonthDot added in v0.1.0

func ToDateMonthDot(t time.Time) DateMonthDot

ToDateMonthDot time.Time to DateMonthDot

func (DateMonthDot) MarshalJSON added in v0.1.0

func (t DateMonthDot) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (DateMonthDot) MarshalText added in v0.1.0

func (t DateMonthDot) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (DateMonthDot) StdTime added in v0.1.0

func (t DateMonthDot) StdTime() time.Time

StdTime convert to standard time

func (DateMonthDot) String added in v0.1.0

func (t DateMonthDot) String() string

String implemented interface Stringer

func (*DateMonthDot) UnmarshalJSON added in v0.1.0

func (t *DateMonthDot) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*DateMonthDot) UnmarshalText added in v0.1.0

func (t *DateMonthDot) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type DateMonthNop added in v0.1.0

type DateMonthNop time.Time

DateMonthNop 格式: 200601

func ToDateMonthNop added in v0.1.0

func ToDateMonthNop(t time.Time) DateMonthNop

ToDateMonthNop time.Time to DateMonthNop

func (DateMonthNop) MarshalJSON added in v0.1.0

func (t DateMonthNop) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (DateMonthNop) MarshalText added in v0.1.0

func (t DateMonthNop) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (DateMonthNop) StdTime added in v0.1.0

func (t DateMonthNop) StdTime() time.Time

StdTime convert to standard time

func (DateMonthNop) String added in v0.1.0

func (t DateMonthNop) String() string

String implemented interface Stringer

func (*DateMonthNop) UnmarshalJSON added in v0.1.0

func (t *DateMonthNop) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*DateMonthNop) UnmarshalText added in v0.1.0

func (t *DateMonthNop) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type DateMonthSlash added in v0.1.0

type DateMonthSlash time.Time

DateMonthSlash 格式: 2006/01

func ToDateMonthSlash added in v0.1.0

func ToDateMonthSlash(t time.Time) DateMonthSlash

ToDateMonthSlash time.Time to DateMonthSlash

func (DateMonthSlash) MarshalJSON added in v0.1.0

func (t DateMonthSlash) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (DateMonthSlash) MarshalText added in v0.1.0

func (t DateMonthSlash) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (DateMonthSlash) StdTime added in v0.1.0

func (t DateMonthSlash) StdTime() time.Time

StdTime convert to standard time

func (DateMonthSlash) String added in v0.1.0

func (t DateMonthSlash) String() string

String implemented interface Stringer

func (*DateMonthSlash) UnmarshalJSON added in v0.1.0

func (t *DateMonthSlash) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*DateMonthSlash) UnmarshalText added in v0.1.0

func (t *DateMonthSlash) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type DateNop added in v0.1.0

type DateNop time.Time

DateNop 格式: 20060102

func ToDateNop added in v0.1.0

func ToDateNop(t time.Time) DateNop

ToDateNop time.Time to DateNop

func (DateNop) MarshalJSON added in v0.1.0

func (t DateNop) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (DateNop) MarshalText added in v0.1.0

func (t DateNop) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (DateNop) StdTime added in v0.1.0

func (t DateNop) StdTime() time.Time

StdTime convert to standard time

func (DateNop) String added in v0.1.0

func (t DateNop) String() string

String implemented interface Stringer

func (*DateNop) UnmarshalJSON added in v0.1.0

func (t *DateNop) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*DateNop) UnmarshalText added in v0.1.0

func (t *DateNop) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type DateSlash added in v0.1.0

type DateSlash time.Time

DateSlash 格式: 2006/01/02

func ToDateSlash added in v0.1.0

func ToDateSlash(t time.Time) DateSlash

ToDateSlash time.Time to DateSlash

func (DateSlash) MarshalJSON added in v0.1.0

func (t DateSlash) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (DateSlash) MarshalText added in v0.1.0

func (t DateSlash) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (DateSlash) StdTime added in v0.1.0

func (t DateSlash) StdTime() time.Time

StdTime convert to standard time

func (DateSlash) String added in v0.1.0

func (t DateSlash) String() string

String implemented interface Stringer

func (*DateSlash) UnmarshalJSON added in v0.1.0

func (t *DateSlash) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*DateSlash) UnmarshalText added in v0.1.0

func (t *DateSlash) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type Quarter added in v0.1.0

type Quarter int

A Quarter specifies a quarter of the year (1, 2 , 3 ,4).

const (
	Quarter1th Quarter = iota + 1 // 1, 2 ,3
	Quarter2th                    // 4, 5, 6
	Quarter3th                    // 7, 8, 9
	Quarter4th                    // 10, 11, 12
)

func GetQuarter added in v0.1.0

func GetQuarter(month time.Month) Quarter

GetQuarter 获取季度

func GetQuarter2 added in v0.1.0

func GetQuarter2(t time.Time) Quarter

GetQuarter2 通过时间获取季度

type Time

type Time time.Time

Time 格式: 2006-01-02 15:04:05

func ParseTime added in v0.1.0

func ParseTime(value string) (Time, error)

ParseTime parse time with layout 2006-01-02 15:04:05

func ToTime added in v0.1.0

func ToTime(t time.Time) Time

ToTime time.Time to Time

func (Time) MarshalJSON added in v0.1.0

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

MarshalJSON implemented interface Marshaler

func (Time) MarshalText added in v0.1.0

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

MarshalText implemented interface TextMarshaler

func (Time) StdTime added in v0.1.0

func (t Time) StdTime() time.Time

StdTime convert to standard time

func (Time) String added in v0.1.0

func (t Time) String() string

String implemented interface Stringer

func (*Time) UnmarshalJSON added in v0.1.0

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*Time) UnmarshalText added in v0.1.0

func (t *Time) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type TimeNop added in v0.1.0

type TimeNop time.Time

TimeNop 格式: 20060102150405

func ToTimeNop added in v0.1.0

func ToTimeNop(t time.Time) TimeNop

ToTimeNop time.Time to TimeNop

func (TimeNop) MarshalJSON added in v0.1.0

func (t TimeNop) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (TimeNop) MarshalText added in v0.1.0

func (t TimeNop) MarshalText() ([]byte, error)

MarshalText implemented interface TextMarshaler

func (TimeNop) StdTime added in v0.1.0

func (t TimeNop) StdTime() time.Time

StdTime convert to standard time

func (TimeNop) String added in v0.1.0

func (t TimeNop) String() string

String implemented interface Stringer

func (*TimeNop) UnmarshalJSON added in v0.1.0

func (t *TimeNop) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

func (*TimeNop) UnmarshalText added in v0.1.0

func (t *TimeNop) UnmarshalText(text []byte) error

UnmarshalText implemented interface TextUnmarshaler

type UnixNanoTimestamp added in v0.1.0

type UnixNanoTimestamp time.Time

UnixNanoTimestamp unix nano 时间戳

func ToUnixNanoTimestamp added in v0.1.0

func ToUnixNanoTimestamp(t time.Time) UnixNanoTimestamp

ToUnixNanoTimestamp time.Time to UnixNanoTimestamp

func (UnixNanoTimestamp) MarshalJSON added in v0.1.0

func (t UnixNanoTimestamp) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (UnixNanoTimestamp) StdTime added in v0.1.0

func (t UnixNanoTimestamp) StdTime() time.Time

StdTime convert to standard time

func (UnixNanoTimestamp) String added in v0.1.0

func (t UnixNanoTimestamp) String() string

String implemented interface Stringer

func (*UnixNanoTimestamp) UnmarshalJSON added in v0.1.0

func (t *UnixNanoTimestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

type UnixTimestamp added in v0.1.0

type UnixTimestamp time.Time

UnixTimestamp unix 时间戳

func ToUnixTimestamp added in v0.1.0

func ToUnixTimestamp(t time.Time) UnixTimestamp

ToUnixTimestamp time.Time to UnixTimestamp

func (UnixTimestamp) MarshalJSON added in v0.1.0

func (t UnixTimestamp) MarshalJSON() ([]byte, error)

MarshalJSON implemented interface Marshaler

func (UnixTimestamp) StdTime added in v0.1.0

func (t UnixTimestamp) StdTime() time.Time

Time convert to standard time

func (UnixTimestamp) String added in v0.1.0

func (t UnixTimestamp) String() string

String implemented interface Stringer

func (*UnixTimestamp) UnmarshalJSON added in v0.1.0

func (t *UnixTimestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON implemented interface Unmarshaler

Jump to

Keyboard shortcuts

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