Documentation ¶
Index ¶
- Constants
- Variables
- func AddDate(date string, add time.Duration, format ...string) time.Time
- func AddDateForInt(date string, years, months, days int, format ...string) time.Time
- func Datetime2TimeObj(target string, format ...string) time.Time
- func Datetime2Timestamp(date string, format ...string) int64
- func DatetimeBetween(target, startDatetime, endDatetime string) bool
- func DatetimeIsExpire(date string, expire ...time.Duration) bool
- func DistinctIds(ids []string) []string
- func DistinctIdsStr(s string, split string) string
- func DistinctInt32Ids(ids []int32) (res []int32)
- func FormatBusinessDate(date string) (finalStr string)
- func GetAgeForBirthday(birthday string, format ...string) (age int)
- func GetDateBetween(startDate, endDate string, args ...int32) []string
- func GetInputStr2ShortStr(input string, size ...int) string
- func GetJson2Dump(data interface{}) string
- func GetJsonPrintStr(v interface{}) string
- func GetPageSliceIndex(page, size int32, l int) (startIndex, endIndex int32)
- func GetPlaceholderStrForNum(size int, num int64, placeholder ...byte) string
- func GetShortStrForRand(size int, kind ...int) string
- func GetTargeMonthDur(target time.Time) (startDatetime, endDatetime string)
- func GetTargetDateDur(target time.Time) (startDatetime, endDatetime string)
- func GetTimeFmt(fmtType int8, splits ...string) string
- func GetWeekInfoForTime(dateFormat string, t ...time.Time) *weekInfo
- func InInt32Array(target int32, in ...int32) bool
- func InString(target string, ins ...string) bool
- func InUint8Array(target uint8, in ...uint8) bool
- func IsExported(fieldName string) bool
- func MurmurHash2Uint64(data []byte) (hash uint64)
- func PriceNum2Str(value int32) string
- func PriceStr2Str(value string) (ans string)
- func RemoveTypePtr(t reflect.Type) reflect.Type
- func RemoveValuePtr(t reflect.Value) reflect.Value
- func Second2Hour(s int) (hour, min, sec int)
- func SubDate(date, sub string, format ...string) time.Duration
- func SubNow2Year(year string) string
- func Timestamp2Datetime(timestamp int64, format ...string) string
- func ToString(src interface{}, jsonEscapeHTML ...bool) string
Constants ¶
const ( DayInt = 24 * 3600 DayDur = 24 * time.Hour StartTimeSuffix = " 00:00:00" EndTimeSuffix = " 23:59:59" GetDateBetweenForDate int32 = 1 // 按日处理 GetDateBetweenForMonth int32 = 2 // 按月处理 GetDateBetweenForYear int32 = 3 // 按年处理 )
const ( // 时间格式 YearFmt int8 = 1 << iota MonthFmt DayFmt HourFmt MinFmt SecFmt MilliFmt // 毫秒 DateFmtFlag = YearFmt | MonthFmt | DayFmt DateTimeFmtFlag = DateFmtFlag | HourFmt | MinFmt | SecFmt MilliDateTimeFmtFlag = DateFmtFlag | HourFmt | MinFmt | SecFmt | MilliFmt )
const ( KCRandKindNum = 0 // 纯数字 KCRandKindLower = 1 // 小写字母 KCRandKindUpper = 2 // 大写字母 KCRandKindAll = 3 // 数字、大小写字母 )
用于获取随机字符串
Variables ¶
var ( DateFmt = GetTimeFmt(DateFmtFlag) // 2006-01-02 DatetimeFmt = GetTimeFmt(DateTimeFmtFlag) // 2006-01-02 15:04:05 )
Functions ¶
func AddDateForInt ¶
AddDateForInt 增加时间
func Datetime2TimeObj ¶
Datetime2TimeObj
func Datetime2Timestamp ¶
Datetime2Timestamp 将时间字符串转为时间戳
func DatetimeBetween ¶
DatetimeBetween 判断目标时间是否在开始时间和结束时间之间
func DatetimeIsExpire ¶
DatetimeIsExpire 判断输入时间是否过期
func DistinctIdsStr ¶
DistinctIdsStr 将输入拼接 id 参数按照指定字符进行去重, 如: DistinctIdsStr("12345,123,20,123,20,15", ",") => 12345,123,20,15
func FormatBusinessDate ¶
FormatBusinessDate 将输入的时间转为业务需要时间, 规则如下: 1. 1分钟内发布的: 刚刚 2. 1小时内发布的: X分钟前 3. 超过1小时, 仍在当天: xx:xx 4. 跨天,但少于24小时: 昨天 xx:xx 5. 跨天, 超过24小时: xxxx-xx-xx xx:xx
func GetAgeForBirthday ¶
GetAgeForBirthday 根据出生日期获取年龄
func GetDateBetween ¶
GetDateBetween 获取开始时间和结束时间中的日期 args[0] 为操作类型, 默认为 GetDateBetweenForDate args[1] 为了防止死循环设置的最大循环次数, 默认 365(1年)
func GetInputStr2ShortStr ¶
GetInputStr2ShortStr size 建议不要传入, 这样会提高重复率
func GetJson2Dump ¶ added in v1.2.6
func GetJson2Dump(data interface{}) string
GetJson2Dump 获取待打印的内容
func GetPageSliceIndex ¶
GetPageSliceIndex 根据page, size对切片进行分页, l 为目标切片的长度
func GetPlaceholderStrForNum ¶
GetPlaceholderStrForNum 获取指定位数占位符的字符串
func GetShortStrForRand ¶
GetShortStrForRand 随机字符串, 默认按照: 数字、大小写字母进行处理
func GetTargeMonthDur ¶
GetCurMonthDur 获取指定月的开始和结束时间
func GetTargetDateDur ¶
GetAddDateDur 获取指定时间的当天开始时间和结束时间
func GetTimeFmt ¶ added in v1.2.6
GetTimeFmt 获取时间格式化 splits 为分隔符 splits[0] 为 [年月日] 的分割符, 默认为 "-" splits[1] 为 [年月日] 和 [时分秒] 的分割符, 默认为 " " splits[2] 为 [时分秒] 的分割符, 默认为 ":"
func GetWeekInfoForTime ¶
GetWeekInfoForTime 根据输入的 time 来获取本周的日期和星期几, 如果没有输入默认按当前时间处理
func MurmurHash2Uint64 ¶
MurmurHash2Uint64 通过 Murmur 获取 hash uint64 的哈希值
func Timestamp2Datetime ¶
Timestamp2Datetime 将时间戳转为时间字符串
Types ¶
This section is empty.