qtime

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date uint32

Date 基于整形存储的日期类型,例如:20240101

func NewDate

func NewDate(t time.Time) Date

NewDate

@Description: 创建日期
@param t 时间
@return Date

func (Date) AddDays

func (d Date) AddDays(day int) Date

AddDays

@Description: 增减天数
@param day 天数
@return Date

func (Date) AddMonths

func (d Date) AddMonths(month int) Date

AddMonths

@Description: 增减月数
@param month 月数
@return Date

func (Date) AddYears

func (d Date) AddYears(year int) Date

AddYears

@Description: 增减年数
@param year 年数
@return Date

func (Date) CurrentToWeekday

func (d Date) CurrentToWeekday(weekday time.Weekday) Date

CurrentToWeekday

@Description: 获取当前日期所在本周指定周几的日期
@param weekday 需要返回周几
@return date 周几日期

func (Date) ForTo

func (d Date) ForTo(endDate Date, interval uint, callback func(curr Date, percent int))

ForTo

@Description: 自动循环遍历日期,并按日返回每天日期
@param endDate 结束日期
@param interval 日期间隔
@param callback 回调
@return int YYYY年+WW周,如 202451

func (Date) MarshalJSON

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

MarshalJSON

@Description: 复写json转换
@return []byte
@return error

func (Date) ToString

func (d Date) ToString() string

ToString

@Description: 根据全局format格式化输出
@return string

func (Date) ToTime

func (d Date) ToTime() time.Time

ToTime

@Description: 转为原生时间对象
@return time.Time

func (*Date) UnmarshalJSON

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

UnmarshalJSON

@Description: 复写json转换
@param data
@return error

func (Date) Week

func (d Date) Week() time.Weekday

Week

@Description: 获取当前日期是周几
@return int YYYY年+WW周,如 202451

func (Date) YearWeek

func (d Date) YearWeek() int

YearWeek

@Description: 获取当前日期所在本年的周数
@return int YYYY年+WW周,如 202451

type DateTime

type DateTime uint64

DateTime 基于整形存储的日期时间类型,例如:20240101105312

func NewDateTime

func NewDateTime(t time.Time) DateTime

NewDateTime

@Description: 创建日期+时间
@param t 时间
@return Date

func (DateTime) AddDays

func (d DateTime) AddDays(day int) Date

AddDays

@Description: 增减天数
@param day 天数
@return Date

func (DateTime) AddHours

func (d DateTime) AddHours(hour int) Date

AddHours

@Description: 增减小时数
@param hour 小时数
@return Date

func (DateTime) AddMinutes

func (d DateTime) AddMinutes(minute int) Date

AddMinutes

@Description: 增减分钟数
@param minute 分钟数
@return Date

func (DateTime) AddMonths

func (d DateTime) AddMonths(month int) Date

AddMonths

@Description: 增减月数
@param month 月数
@return Date

func (DateTime) AddSeconds

func (d DateTime) AddSeconds(second int) Date

AddSeconds

@Description: 增减秒数
@param second 秒数
@return Date

func (DateTime) AddYears

func (d DateTime) AddYears(year int) Date

AddYears

@Description: 增减年数
@param year 年数
@return Date

func (DateTime) CurrentToWeekday

func (d DateTime) CurrentToWeekday(weekday time.Weekday) DateTime

CurrentToWeekday

@Description: 获取当前日期所在本周指定周几的日期
@param weekday 需要返回周几
@return date 周几日期

func (DateTime) ForTo

func (d DateTime) ForTo(endDate DateTime, interval uint, callback func(curr DateTime, percent int))

ForTo

@Description: 自动循环遍历日期,并按日返回每天日期
@param endDate 结束日期
@param interval 日期间隔
@param callback 回调
@return int YYYY年+WW周,如 202451

func (DateTime) MarshalJSON

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

MarshalJSON

@Description: 复写json转换
@return []byte
@return error

func (DateTime) ToString

func (d DateTime) ToString() string

ToString

@Description: 根据全局format格式化输出
@return string

func (DateTime) ToTime

func (d DateTime) ToTime() time.Time

ToTime

@Description: 转为原生时间对象
@return time.Time

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON

@Description: 复写json转换
@param data
@return error

func (DateTime) Week

func (d DateTime) Week() time.Weekday

Week

@Description: 获取当前日期是周几
@return int YYYY年+WW周,如 202451

func (DateTime) YearWeek

func (d DateTime) YearWeek() int

YearWeek

@Description: 获取当前日期所在本能的周数
@return int YYYY年+WW周,如 202451

Jump to

Keyboard shortcuts

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