Documentation ¶
Index ¶
- Constants
- Variables
- func AddDate(t time.Time, years, months, days int) time.Time
- func GetArbitrarilyTimeStr(increment time.Duration) string
- func GetCstZone() *time.Location
- func GetLastDayTimeStrUnderline() string
- func GetNowDayTimeStr() string
- func GetNowDayTimeStrUnderline() string
- func GetNowTime() time.Time
- func GetNowTimeDate() string
- func GetNowTimeDateUnderline() string
- func GetNowTimeHourUnderline() string
- func GetNowTimeStr() string
- func GetSubMonthDiffer(max, min time.Time) (month int)
- func GetTimeDateMonthBeginAndEnd(times time.Time) ([]string, error)
- func GetTimeDatePartition(startDate string, endDate string) ([]string, error)
- func OverFormatTime(formatTime string) string
- func TimePare(timeStr string) (time.Time, error)
- func TimeParseDate(s string) (time.Time, error)
- func TimeParseDateUnSeparator(s string) (time.Time, error)
- func TimeParseMonth(s string) (time.Time, error)
- func TimeParseYear(s string) (time.Time, error)
- type TimeHelper
- func (t *TimeHelper) GetDay() int
- func (t *TimeHelper) GetHour() int
- func (t *TimeHelper) GetMinute() int
- func (t *TimeHelper) GetMonth() int
- func (t *TimeHelper) GetNextDayHour(hour int) *TimeHelper
- func (t *TimeHelper) GetNextDayHourTimeDuration(hour int) time.Duration
- func (t *TimeHelper) GetSecond() int
- func (t *TimeHelper) GetSubDay(day int) string
- func (t *TimeHelper) GetSubDayTime(day int) time.Time
- func (t *TimeHelper) GetSubMonth(month int) string
- func (t *TimeHelper) GetSubMonthTime(month int) time.Time
- func (t *TimeHelper) GetTime() time.Time
- func (t *TimeHelper) GetWeekDay() *TimeWeek
- func (t *TimeHelper) GetYear() int
- func (t *TimeHelper) ToAll() string
- func (t *TimeHelper) ToDate() string
- func (t *TimeHelper) ToDateIntStr() string
- func (t *TimeHelper) ToDateSecondIntStr() string
- func (t *TimeHelper) ToDateUnderLine() string
- func (t *TimeHelper) ToHour() string
- func (t *TimeHelper) ToHourUnderLine() string
- func (t *TimeHelper) ToMillisecond() int64
- func (t *TimeHelper) ToMinute() string
- func (t *TimeHelper) ToMonth() string
- func (t *TimeHelper) ToUnix() int64
- func (t *TimeHelper) WeekByDate(time time.Time) *TimeWeek
- type TimeHelperReponseWeekDate
- type TimeWeek
Constants ¶
const ( ANSIC = "Mon Jan _2 15:04:05 2006" UnixDate = "Mon Jan _2 15:04:05 MST 2006" RubyDate = "Mon Jan 02 15:04:05 -0700 2006" RFC822 = "02 Jan 06 15:04 MST" RFC822Z = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone RFC850 = "Monday, 02-Jan-06 15:04:05 MST" RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST" RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone RFC3339 = "2006-01-02T15:04:05Z07:00" RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00" Kitchen = "3:04PM" Stamp = "Jan _2 15:04:05" StampMilli = "Jan _2 15:04:05.000" StampMicro = "Jan _2 15:04:05.000000" StampNano = "Jan _2 15:04:05.000000000" UTFALL_SECOND = "2006-01-02 15:04:05" UTFALL_MINUTE = "2006-01-02 15:04" UTFALL_HOUR_UNDERLINE = "2006_01_02_15" UTFALL_HOUR = "2006-01-02 15" UTFALL_DATE_UNDERLINE = "2006_01_02" UTFALL_DATE = "2006-01-02" UTFMONTH = "2006-01" UTFYEAR = "2006" TTFALL_DATE_INT = "20060102" UTFALL_DATE_INT_SECOND = "20060102150405" )
Variables ¶
var TIME_ERROR_ZERO = errors.New("empty time")
Functions ¶
func GetArbitrarilyTimeStr ¶
* 获取与当前时间计算后的值并返回字符串 2021-12-21 23:59:59
func GetCstZone ¶ added in v1.1.48
func GetLastDayTimeStrUnderline ¶
func GetLastDayTimeStrUnderline() string
* 获取昨天的日期 如: 当前时间为 2022-11-01 则返回:2022_10_31
func GetNowTimeHourUnderline ¶
func GetNowTimeHourUnderline() string
* 获取当前时间 日期+小时,用下划线分隔 2021_12_21_23
func GetSubMonthDiffer ¶ added in v1.1.38
* 返回两个日期相差几个月 @param max time.Time @param min time.Time
func GetTimeDateMonthBeginAndEnd ¶ added in v1.1.49
* 当前时间当前月的开始与结束日期
func GetTimeDatePartition ¶ added in v1.1.21
* 获取两个日期间隔的日期明细 @param startDate string [true] 开始日期 [如:2022-06-14] @param endDate string [true] 结束日期 [如:2022-06-16]
@return []string{} exp: []string{2022-06-14, 2022-06-15, 2022-06-16}
func TimeParseDate ¶
* 解析时间日期字符串到时间戳 @param s string 时间日期字符串 : 2022-05-16
func TimeParseDateUnSeparator ¶
* 无字符串分隔 解析时间日期字符串到时间戳 @param string 时间日期字符串 : 20220516
func TimeParseMonth ¶ added in v1.1.43
* 解析日期字符串到时间戳 @param s string 日期字符串: 2022-05
Types ¶
type TimeHelper ¶
type TimeHelper struct {
// contains filtered or unexported fields
}
func NewNowTime ¶
func NewNowTime() *TimeHelper
func TimeParseUnixSecondToDate ¶ added in v1.1.47
func TimeParseUnixSecondToDate(unixTime int64) (*TimeHelper, error)
* 解析秒级时间戳到日期
func (*TimeHelper) GetNextDayHour ¶
func (t *TimeHelper) GetNextDayHour(hour int) *TimeHelper
* 获取第二天的指定小时
如当前为2022-03-20 12:00:00 传入hour 后 如:3 获取到的值为 2022-03-21 03:00:00
@param hour int 指定小时, 24小时制
func (*TimeHelper) GetNextDayHourTimeDuration ¶
func (t *TimeHelper) GetNextDayHourTimeDuration(hour int) time.Duration
* 获取距离下一天指定小时还有多少时间 如当前为2022-03-20 00:10:00 传入hour 后 如:3 返回为 26h50m0s
@param hour int 指定小时, 24小时制
func (*TimeHelper) GetSubDay ¶
func (t *TimeHelper) GetSubDay(day int) string
* 获取时间指定差积的时间[天] [逻辑] 1. 根据传入time 获取当前时间 2. 传day 获取间隔的天数, 如:
- 当前时间为: 2022-03-24, day: 1 则返回 2022-03-25
- 当前时间为: 2022-03-24, day: -1 赠返回 2022-03-23
@param day int 正负整数
func (*TimeHelper) GetSubDayTime ¶
func (t *TimeHelper) GetSubDayTime(day int) time.Time
* 获取时间返回 时间戳 [逻辑] 1. 根据传入time 获取当前时间 2. 传day 获取间隔的天数, 如:
- 当前时间为: 2022-03-24, day: 1 则返回 2022-03-25 这里为time.Time
- 当前时间为: 2022-03-24, day: -1 赠返回 2022-03-23 这里为time.Time
@param day int 正负整数
func (*TimeHelper) GetSubMonth ¶ added in v1.1.37
func (t *TimeHelper) GetSubMonth(month int) string
* 获取时间指定差积的时间[月] [逻辑] 1. 根据传入time 获取当前时间 2. 传day 获取间隔的天数, 如:
- 当前时间为: 2022-03, day: 1 则返回 2022-02
- 当前时间为: 2022-03, day: -1 赠返回 2022-02
@param day int 正负整数
func (*TimeHelper) GetSubMonthTime ¶ added in v1.1.37
func (t *TimeHelper) GetSubMonthTime(month int) time.Time
* 获取上个月[月] 返回time [逻辑] 1. 根据传入time 获取当前时间 2. 传day 获取间隔的天数, 如:
- 当前时间为: 2022-03-06, day: 1 则返回 2022-02-06
- 当前时间为: 2022-03-06, day: -1 赠返回 2022-02-06
@param month int 正负整数
func (*TimeHelper) ToDateIntStr ¶
func (t *TimeHelper) ToDateIntStr() string
* 获取日期字符串(无符号) 20220320
func (*TimeHelper) ToDateSecondIntStr ¶ added in v1.1.36
func (t *TimeHelper) ToDateSecondIntStr() string
* 获取当前时间字符串(精到秒 无符号)
func (*TimeHelper) ToDateUnderLine ¶
func (t *TimeHelper) ToDateUnderLine() string
* 获取日期字符串,用下划线分隔 2021_12_21
func (*TimeHelper) ToHourUnderLine ¶
func (t *TimeHelper) ToHourUnderLine() string
* 获取小时,用下划线分隔 2021_12_21_23
func (*TimeHelper) ToMillisecond ¶ added in v1.1.46
func (t *TimeHelper) ToMillisecond() int64
* 获取时间毫秒
func (*TimeHelper) ToMonth ¶ added in v1.1.166
func (t *TimeHelper) ToMonth() string
*
- 日期月字符串
- 2021-12
type TimeHelperReponseWeekDate ¶ added in v1.1.164
type TimeHelperReponseWeekDate struct { Year int // 年 Month int // 月 Day int // 日 WeekAllNumber int // 总年第几周 StartTime time.Time // 当周当月开始时间 EndTime time.Time // 当周当月结束时间 }
*
- 响数据据返回当前时间的第几周及日期数据
func GetSubDateTimeStrWeekDate ¶ added in v1.1.164
func GetSubDateTimeStrWeekDate(timeData time.Time) *TimeHelperReponseWeekDate
*
- 当前日期属于当前第几周,当月第几周及当前当前周开始时间