udwTime

package
v0.0.0-...-f254aa5 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: MIT Imports: 11 Imported by: 12

Documentation

Index

Constants

View Source
const (
	FormatMysqlZero  = "0000-00-00 00:00:00"
	FormatMysql      = "2006-01-02 15:04:05"
	FormatMysqlUs    = "2006-01-02 15:04:05.999999"
	FormatMysqlNs    = "2006-01-02T15:04:05.999999999"
	FormatMysqlNsV2  = "2006-01-02 15:04:05.999999999"
	FormatMysqlNsV3  = "2006-01-02T15-04-05.999999999"
	FormatFileName   = "2006-01-02_15-04-05"
	FormatFileNameV2 = "2006-01-02-15-04-05"

	FormatDateMysql = "2006-01-02"
	FormatMysqlDate = "2006-01-02"

	FormatZoneOffsetMysql   = "2006-01-02 15:04:05 -0700"
	FormatZoneOffsetMysqlV2 = "2006-01-02 15:04:05 -0700 CST"
	Iso3339Hour             = "2006-01-02T15"
	Iso3339Minute           = "2006-01-02T15:04"
	Iso3339Second           = "2006-01-02T15:04:05"
	FormatDbTimeSecond      = Iso3339Second
	AppleJsonFormat         = "2006-01-02 15:04:05 Etc/MST"
	AppleJsonFormatV2       = "2006-01-02 15:04:05 MST"
	Iso8601                 = "2006-01-02T15:04Z"
	Iso8601GMT              = "2006-01-02T15:04:05Z"

	FormatMysqlMinute           = "2006-01-02 15:04"
	FormatMysqlMouthAndDay      = "01-02"
	FormatMysqlYearAndMoney     = "2006-01"
	FormatInternational         = "Monday, 02 January 2006"
	FormatHourAndMinute         = "15:04"
	FormatMouthDayHourAndMinute = "01-02 15:04"

	FormatDateAndHour           = "2006-01-02 15"
	FormatUdwLog                = "20060102T15:04:05.000000-07"
	FormatDateTimeDigitalSecond = "20060102150405"
)
View Source
const (
	Day        = 24 * time.Hour
	Month      = 30 * Day
	Year       = 365 * Day
	YearSecond = 365 * 24 * 60 * 60
	WeekSecond = 7 * 24 * 60 * 60
)

Variables

View Source
var DefaultNower tDefaultNower
View Source
var MysqlEnd = "9999-12-31 23:59:59"
View Source
var MysqlStart = "0000-01-01 00:00:00"

Functions

func CountMonthLeftDay

func CountMonthLeftDay(t time.Time, loc *time.Location) int

func DateFormatInUtc2

func DateFormatInUtc2(t time.Time) string

func DateStringToTimeInDefault

func DateStringToTimeInDefault(s string) (t time.Time, err error)

func DateSub

func DateSub(t1 time.Time, t2 time.Time, loc *time.Location) time.Duration

func DateSubLocal

func DateSubLocal(t1 time.Time, t2 time.Time) time.Duration

func DateSubToDay

func DateSubToDay(t1 time.Time, t2 time.Time, loc *time.Location) int

func DateSubToHour

func DateSubToHour(t1 time.Time, t2 time.Time, loc *time.Location) int

func DbTimeGetMaxValue

func DbTimeGetMaxValue() string

func DbTimeGetMinValue

func DbTimeGetMinValue() string

func DbTimeGetObjFromString

func DbTimeGetObjFromString(s string) (t time.Time, err error)

func DbTimeGetObjFromStringIgnoreError

func DbTimeGetObjFromStringIgnoreError(s string) time.Time

func DbTimeGetObjFromUint64

func DbTimeGetObjFromUint64(u uint64) (t time.Time)

func DbTimeGetObjFromUint64Second

func DbTimeGetObjFromUint64Second(u uint64) (t time.Time)

func DbTimeGetStringFromObj

func DbTimeGetStringFromObj(t time.Time) string

func DbTimeGetStringFromObjV2

func DbTimeGetStringFromObjV2(t time.Time) string

func DbTimeGetUint64FromObjOrMax

func DbTimeGetUint64FromObjOrMax(t time.Time) uint64

func DbTimeGetUint64SecondFromObj

func DbTimeGetUint64SecondFromObj(t time.Time) uint64

func DefaultAgeFormat

func DefaultAgeFormat(targetTime time.Time, now time.Time) string

func DefaultDateFormat

func DefaultDateFormat(t time.Time) string

func DefaultFormat

func DefaultFormat(t time.Time) string

func DefaultFormatLocal

func DefaultFormatLocal(t time.Time) string

func DefaultFormatNs

func DefaultFormatNs(t time.Time) string

func DefaultFormatNsFixSize

func DefaultFormatNsFixSize(t time.Time) string

func DefaultFormatSecondV2

func DefaultFormatSecondV2(t time.Time) string

func DefaultMysqlFormat

func DefaultMysqlFormat(t time.Time) string

func DefaultTimeAndAgeFormat

func DefaultTimeAndAgeFormat(targetTime time.Time, now time.Time) string

func DurationFormat

func DurationFormat(dur time.Duration) string

func DurationFormatBefore

func DurationFormatBefore(dur time.Duration) string

func DurationFormatByHourMin

func DurationFormatByHourMin(dur time.Duration) string

func DurationFormatFloat64Ns

func DurationFormatFloat64Ns(dur float64) string

func DurationFormatFloat64Seconds

func DurationFormatFloat64Seconds(dur float64) string

func DurationFormatPadding

func DurationFormatPadding(dur time.Duration) string

func DurationFormatTimeMysql

func DurationFormatTimeMysql(dur time.Duration) string

func FixClockTimeSleep

func FixClockTimeSleep(dur time.Duration)

func FixClockTimeSleepToTimeInDay

func FixClockTimeSleepToTimeInDay(offset time.Duration, zone *time.Location)

func FixClockTimeSleepToTimeInDayInDefaultTimeZone

func FixClockTimeSleepToTimeInDayInDefaultTimeZone(offset time.Duration)

func FixClockTimeSleepWithOffset

func FixClockTimeSleepWithOffset(dur time.Duration, offset time.Duration)

func FixLocalTimeToOffsetSpecifiedZoneTime

func FixLocalTimeToOffsetSpecifiedZoneTime(timeOffset int, localTime string) string

func FormatDefaultRfc3339

func FormatDefaultRfc3339(t time.Time) string

func FormatMysqlMinuteInTz

func FormatMysqlMinuteInTz(t time.Time, tz *time.Location) string

func FormatRfc3339NanoNoTz

func FormatRfc3339NanoNoTz(t time.Time) string

func FormatTimeZone

func FormatTimeZone(tz *time.Location) string

func FromUnixFloat

func FromUnixFloat(f float64) time.Time

func FromUnixInt64

func FromUnixInt64(f int64) time.Time

func FromUnixMillisecondsInt64

func FromUnixMillisecondsInt64(f int64) time.Time

func FromUnixNano

func FromUnixNano(f uint64) time.Time

func FromUnixNanoInt64

func FromUnixNanoInt64(f int64) time.Time

func GetDefaultTimeZone

func GetDefaultTimeZone() *time.Location

func GetDurToNextWeek

func GetDurToNextWeek(weekday time.Weekday, hour int) time.Duration

func GetDurationToNextWeek

func GetDurationToNextWeek(weekday time.Weekday, offset time.Duration) time.Duration

func GetFixedZoneByTzSecond

func GetFixedZoneByTzSecond(locOffset int) *time.Location

func GetLastWeek

func GetLastWeek(weekday time.Weekday, sometime time.Time) time.Time

func GetMaxTime

func GetMaxTime() time.Time

func GetNextTimeDuration

func GetNextTimeDuration(hour int, minute int) time.Duration

func GetNextWeek

func GetNextWeek(weekday time.Weekday, sometime time.Time) time.Time

func GetPeriodFromGenericSortedList

func GetPeriodFromGenericSortedList(t time.Time, SortedList interface{}) (index int, err error)

func GetPeriodFromSortedList

func GetPeriodFromSortedList(t time.Time, SortedList []Period) (index int, ok bool)

func GetSubSeconds

func GetSubSeconds(a time.Time, b time.Time) int64

func GetThisWeek

func GetThisWeek(weekday time.Weekday, sometime time.Time) time.Time

func GetTimePointInBetween

func GetTimePointInBetween(req GetTimePointInBetweenRequest) int

func GetUnixFloat

func GetUnixFloat(t1 time.Time) float64

func GetUtc2Zone

func GetUtc2Zone() *time.Location

func GetUtc8Zone

func GetUtc8Zone() *time.Location

func GetUtcD4Zone

func GetUtcD4Zone() *time.Location

func GetUtcD5Zone

func GetUtcD5Zone() *time.Location

func GetUtcD7Zone

func GetUtcD7Zone() *time.Location

func GetUtcD8Zone

func GetUtcD8Zone() *time.Location

func HourAndMinuteFormatLocal

func HourAndMinuteFormatLocal(t time.Time) string

func IsSameDay

func IsSameDay(t1 time.Time, t2 time.Time, loc *time.Location) bool

func IsSameHour

func IsSameHour(t1 time.Time, t2 time.Time, loc *time.Location) bool

func IsSameMonth

func IsSameMonth(t1 time.Time, t2 time.Time, loc *time.Location) bool

func ModBySecond

func ModBySecond(t1 time.Time) time.Time

func MonthAndDayFormat

func MonthAndDayFormat(t time.Time) string

func MonthDayYearFormat

func MonthDayYearFormat(t time.Time) string

func MonthLeftPercent

func MonthLeftPercent(t time.Time, loc *time.Location) float64

func MustDateMysqlFormat

func MustDateMysqlFormat(t string)

func MustDateStringAddDay

func MustDateStringAddDay(s string, dayNum int) string

func MustDateStringSubToDay

func MustDateStringSubToDay(s1 string, s2 string) int

func MustDateStringToTime

func MustDateStringToTime(s string, tz *time.Location) (t time.Time)

func MustDbTimeDescGetObjFromString

func MustDbTimeDescGetObjFromString(s string) (t time.Time)

func MustDbTimeDescGetStringFromObj

func MustDbTimeDescGetStringFromObj(t time.Time) string

func MustDbTimeGetObjFromString

func MustDbTimeGetObjFromString(s string) time.Time

func MustDbTimeGetObjFromStringIgnoreEmpty

func MustDbTimeGetObjFromStringIgnoreEmpty(s string) time.Time

func MustDbTimeGetStringFromObj

func MustDbTimeGetStringFromObj(t time.Time) string

func MustDbTimeHourGetObjFromString

func MustDbTimeHourGetObjFromString(s string) time.Time

func MustDbTimeHourGetStringFromObj

func MustDbTimeHourGetStringFromObj(t time.Time) string

func MustDbTimeSecondGetStringFromObj

func MustDbTimeSecondGetStringFromObj(t time.Time) string

func MustFromLocalMysqlFormat

func MustFromLocalMysqlFormat(timeString string) time.Time

func MustFromMysqlDateFormat

func MustFromMysqlDateFormat(timeString string) time.Time

func MustFromMysqlFormat

func MustFromMysqlFormat(timeString string) time.Time

func MustFromMysqlFormatDefaultTZ

func MustFromMysqlFormatDefaultTZ(timeString string) time.Time

func MustFromMysqlFormatInLocation

func MustFromMysqlFormatInLocation(timeString string, loc *time.Location) time.Time

func MustNotTimeout

func MustNotTimeout(f func(), dur time.Duration)

func MustParseAutoInDefault

func MustParseAutoInDefault(sTime string) (t time.Time)

func MustParseAutoInDefaultIgnoreEmpty

func MustParseAutoInDefaultIgnoreEmpty(sTime string) (t time.Time)

func MustParseAutoInLocal

func MustParseAutoInLocal(sTime string) (t time.Time)

func MustParseAutoInUTC

func MustParseAutoInUTC(sTime string) (t time.Time)

func MustParseFormatDateMysqlInDefaultTz

func MustParseFormatDateMysqlInDefaultTz(tS string) (t time.Time)

func MustParseFormatDateMysqlInTz

func MustParseFormatDateMysqlInTz(tS string, tz *time.Location) (t time.Time)

func MustSplitMysqlDateFormatPrefix

func MustSplitMysqlDateFormatPrefix(s string) (datePart string, remainPart string)

func MysqlNowFromDefaultNower

func MysqlNowFromDefaultNower() string

func MysqlUsFormat

func MysqlUsFormat(t time.Time) string

func MysqlUsNowFromDefaultNower

func MysqlUsNowFromDefaultNower() string

func NowFromDefaultNower

func NowFromDefaultNower() (out time.Time)

func NowWithFileNameFormatV2

func NowWithFileNameFormatV2() string

func ParseAutoInDefault

func ParseAutoInDefault(sTime string) (t time.Time, err error)

func ParseAutoInLocal

func ParseAutoInLocal(sTime string) (t time.Time, err error)

func ParseAutoInLocation

func ParseAutoInLocation(sTime string, loc *time.Location) (t time.Time, err error)

func ParseFormatDateMysqlInDefaultTz

func ParseFormatDateMysqlInDefaultTz(tS string) (t time.Time, errMsg string)

func ParseMillStringToTime

func ParseMillStringToTime(mill string) (time.Time, error)

func PeriodListSort

func PeriodListSort(PeriodList PeriodListInterface)

func PeriodSort

func PeriodSort(p []Period)

func PstTimeZoneDateFormat

func PstTimeZoneDateFormat(t time.Time) string

func SelectPeriodFromSortedPeriodList

func SelectPeriodFromSortedPeriodList(t time.Time, PeriodList PeriodListInterface) (index int, ok bool)

func SetDefaultNowerCallback

func SetDefaultNowerCallback(cb func() time.Time)

func SetDefaultNowerToFixTime

func SetDefaultNowerToFixTime(t time.Time)

func SetDefaultNowerToFixTimeString

func SetDefaultNowerToFixTimeString(s string)

func SetDefaultNowerToOffset

func SetDefaultNowerToOffset(offset time.Duration)

func SetDefaultNowerToRealTime

func SetDefaultNowerToRealTime()

func SleepLoopWithFixDuration

func SleepLoopWithFixDuration(req FixTimeDurationLoopRequest)

func SleepToTodayTimePoint

func SleepToTodayTimePoint(now time.Time, d time.Duration)

func TimeIntSecConvert

func TimeIntSecConvert(sec int) string

func Timeout

func Timeout(f func(), dur time.Duration) (hasTimeout bool)

func ToDate

func ToDate(t time.Time) time.Time

func ToDateDefault

func ToDateDefault(t time.Time) time.Time

func ToDateString

func ToDateString(t time.Time) string

func ToDateStringInDefaultTz

func ToDateStringInDefaultTz(t time.Time) string

func ToLocal

func ToLocal(t time.Time) time.Time

func ToMonth

func ToMonth(t time.Time, loc *time.Location) time.Time

func ToMonthWithOffset

func ToMonthWithOffset(t time.Time, loc *time.Location, offset int) time.Time

func UdwLogFormat

func UdwLogFormat(t time.Time) string

func UnixNanoNow

func UnixNanoNow() int64

func YearMonthFormat

func YearMonthFormat(t time.Time) string

Types

type DateStringPeriod

type DateStringPeriod struct {
	StartInclude string
	EndInclude   string
}

type FixTimeDurationLoopRequest

type FixTimeDurationLoopRequest struct {
	FixSleepDur          time.Duration
	RandomDurRange       time.Duration
	SleepDurAfterTimeout time.Duration
	Fn                   func()
}

type GetTimePointInBetweenRequest

type GetTimePointInBetweenRequest struct {
	StartTime time.Time
	EndTime   time.Time
	Duration  time.Duration
}

type MonthDate

type MonthDate uint32

func MonthDateFromTime

func MonthDateFromTime(t time.Time) MonthDate

func (MonthDate) DayNum

func (m MonthDate) DayNum() int

func (MonthDate) IsValid

func (m MonthDate) IsValid() bool

func (MonthDate) Month

func (m MonthDate) Month() time.Month

func (MonthDate) Year

func (m MonthDate) Year() int

type Period

type Period struct {
	Start time.Time
	End   time.Time
}

func GetOneWeekPeriodArray

func GetOneWeekPeriodArray(sometime time.Time) (periodArray [7]Period)

func MustNewPeriod

func MustNewPeriod(Start time.Time, End time.Time) (period Period)

func NewPeriod

func NewPeriod(Start time.Time, End time.Time) (period Period, err error)

func NewPeriodPassed24Hours

func NewPeriodPassed24Hours() Period

func (Period) HasData

func (p Period) HasData() bool

func (Period) IsIn

func (p Period) IsIn(t time.Time) bool

func (Period) IsValid

func (p Period) IsValid() bool

func (Period) IsZero

func (p Period) IsZero() bool

func (Period) Overlaps

func (p Period) Overlaps(b Period) bool

type PeriodGetter

type PeriodGetter interface {
	GetPeriod() Period
}

type PeriodHour

type PeriodHour struct {
	Start int
	End   int
}

type PeriodList

type PeriodList []PeriodListElement

func (PeriodList) Append

func (p PeriodList) Append(period Period) PeriodList

func (PeriodList) IsIncludeOverlap

func (p PeriodList) IsIncludeOverlap() bool

func (PeriodList) Len

func (p PeriodList) Len() int

func (PeriodList) Less

func (p PeriodList) Less(i, j int) bool

func (PeriodList) SelectFromTime

func (p PeriodList) SelectFromTime(t time.Time) (OriginIndex int, ok bool)

func (PeriodList) SetAtIndex

func (p PeriodList) SetAtIndex(period Period, i int)

func (PeriodList) Sort

func (p PeriodList) Sort()

func (PeriodList) Swap

func (p PeriodList) Swap(i, j int)

type PeriodListElement

type PeriodListElement struct {
	Period      Period
	OriginIndex int
}

type PeriodListInterface

type PeriodListInterface interface {
	Len() int
	GetPeriodAtIndex(i int) Period
	Swap(i, j int)
}

type PeriodSlice

type PeriodSlice []Period

func (PeriodSlice) Len

func (p PeriodSlice) Len() int

func (PeriodSlice) Less

func (p PeriodSlice) Less(i, j int) bool

func (PeriodSlice) Swap

func (p PeriodSlice) Swap(i, j int)

type TimeRecoverInt

type TimeRecoverInt struct {
	Num             int
	Max             int
	LastRecoverTime time.Time
	AddDuration     time.Duration
}

func (*TimeRecoverInt) Full

func (t *TimeRecoverInt) Full(now time.Time)

func (*TimeRecoverInt) Sync

func (t *TimeRecoverInt) Sync(now time.Time)

type TtlStringTimeMap

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

func TtlStringTimeMapNew

func TtlStringTimeMapNew(ttlDuration time.Duration) *TtlStringTimeMap

func (*TtlStringTimeMap) Add

func (s *TtlStringTimeMap) Add(key string, t time.Time, now time.Time) (has bool)

func (*TtlStringTimeMap) AddNow

func (s *TtlStringTimeMap) AddNow(key string, now time.Time) (has bool)

Jump to

Keyboard shortcuts

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