Documentation ¶
Index ¶
- Constants
- func CeilingTimeNow() time.Time
- func CountDaysOfMonth(year int, month int) (days int)
- func CurrentTimeFormat() string
- func CurrentTimeLayout(layout string) string
- func CurrentTimeMicrosecond() int64
- func CurrentTimeMillisecond() int64
- func CurrentTimeNanosecond() int64
- func CurrentTimeSecond() int64
- func CurrentYear() string
- func DateStrSubDays3(start, end string) (int, error)
- func DateSubReturnDays(start, end time.Time) (int, error)
- func FirstDayOfCurrentYearAsString() string
- func FloorTimeNow() time.Time
- func FormatDate(date time.Time, format string) string
- func FormatDate1(date time.Time) string
- func FormatDate2(date time.Time) string
- func FormatDate3(date time.Time) string
- func FormatDate4(date time.Time) string
- func FormatTime(tm time.Time, forStr string) string
- func Future(sec int, f func())
- func GetBeginTimeToday() time.Time
- func GetDateAsDefaultStr() string
- func GetDay0(timestamp int64) time.Time
- func GetDayStr(tm time.Time) string
- func GetEndtime(format string) time.Time
- func GetHour(timestamp int64) int
- func GetHour0(timestamp int64) time.Time
- func GetLastDayCurrentTime(timestamp int64, offset int) time.Time
- func GetLastMonthStartAndEnd() (time.Time, time.Time)
- func GetLocalTime(tm time.Time) time.Time
- func GetMonth0(timestamp int64) time.Time
- func GetShowTime(ts time.Time) string
- func GetSysTimeLayout() string
- func GetTimeStr(tm time.Time) string
- func GetTimeWeek(timestamp int64) int
- func GetUtcDay0(now time.Time, timeZone *time.Location) int64
- func GetUtcTime(tm time.Time) int64
- func GetUtcWeek0(timestamp int64) int64
- func GetWeek0(timestamp int64) time.Time
- func IsDate3(date string) (bool, error)
- func ParseDate(date string, format string) (time.Time, error)
- func ParseDate1(date string) (time.Time, error)
- func ParseDate2(date string) (time.Time, error)
- func ParseDate3(date string) (time.Time, error)
- func ParseTime(timeStr string) (time.Time, error)
- func SecondsToTimesStr1(seconds int) string
- func SecondsToTimesStr2(seconds int) string
- func StrToTime(tStr, format string, timeZone *time.Location) time.Time
- func StringTimetoUnix(timestr string) int64
- func Time2Unix(t time.Time) int64
- func Time2UnixNano(t time.Time) int64
- func TimeDayDuratioin(day float64) time.Duration
- func TimeHourDuratioin(hour float64) time.Duration
- func TimeMicrosecondDuration(m float64) time.Duration
- func TimeMillisecondDuration(m float64) time.Duration
- func TimeMinuteDuration(minute float64) time.Duration
- func TimeNanosecondDuration(n float64) time.Duration
- func TimeSecondDuration(sec float64) time.Duration
- func TimeStrSub(start, end, format string) (int64, error)
- func TimeToShortString(ts time.Time) string
- func TimeToString(ts time.Time) string
- func TimerByHour(f func())
- func Unix2Time(unix int64) time.Time
- func UnixNano2Time(nano int64) time.Time
- func UnixString2Time(unix string) (time.Time, error)
- func UnixToTime(timestamp int64) time.Time
- func YMD(year int, month int, day int, hour int, minute int, sec int) int
- func YMDPrint(sec int, nsec int) string
- func YMDUTC(year int, month int, day int, hour int, minute int, sec int) int
- type Date
- func (d *Date) LastMonthEndDate() string
- func (d *Date) LastMonthEndDateTime() string
- func (d *Date) LastMonthStartDate() string
- func (d *Date) LastMonthStartDateTime() string
- func (d *Date) LastWeekEndDate() string
- func (d *Date) LastWeekEndDateTime() string
- func (d *Date) LastWeekStartDate() string
- func (d *Date) LastWeekStartDateTime() string
- func (d *Date) LastYearEndDate() string
- func (d *Date) LastYearEndDateTime() string
- func (d *Date) LastYearStartDate() string
- func (d *Date) LastYearStartDateTime() string
- func (d *Date) MonthStartDate() string
- func (d *Date) MonthStartDateTime() string
- func (d *Date) TodayDate() string
- func (d *Date) TodayDateTime() string
- func (d *Date) TodayEndDateTime() string
- func (d *Date) TodayStartDateTime() string
- func (d *Date) TomorrowDate() string
- func (d *Date) TomorrowEndDateTime() string
- func (d *Date) TomorrowStartDateTime() string
- func (d *Date) WeekStartDate() string
- func (d *Date) YearStartDate() string
- func (d *Date) YearStartDateTime() string
- func (d *Date) YesterdayDate() string
- func (d *Date) YesterdayEndDateTime() string
- func (d *Date) YesterdayStartDateTime() string
- type DateHandler
- type GoTime
- func (d GoTime) FormatDateString() string
- func (d GoTime) FormatDateTimeEndString() string
- func (d GoTime) FormatDateTimeStartString() string
- func (d GoTime) FormatDateTimeString() string
- func (d GoTime) LastMonth() GoTime
- func (d GoTime) LastMonthEnd() GoTime
- func (d GoTime) LastMonthStart() GoTime
- func (d GoTime) LastWeek() GoTime
- func (d GoTime) LastWeekEnd() GoTime
- func (d GoTime) LastWeekStart() GoTime
- func (d GoTime) LastYear() GoTime
- func (d GoTime) LastYearEnd() GoTime
- func (d GoTime) LastYearStart() GoTime
- func (d GoTime) MonthEnd() GoTime
- func (d GoTime) MonthStart() GoTime
- func (d GoTime) NextMonth() GoTime
- func (d GoTime) NextMonthAfterStart() GoTime
- func (d GoTime) NextMonthEnd() GoTime
- func (d GoTime) NextMonthStart() GoTime
- func (d GoTime) NextWeek() GoTime
- func (d GoTime) NextWeekEnd() GoTime
- func (d GoTime) NextWeekStart() GoTime
- func (d GoTime) NextYear() GoTime
- func (d GoTime) NextYearAfterStart() GoTime
- func (d GoTime) NextYearEnd() GoTime
- func (d GoTime) NextYearStart() GoTime
- func (d GoTime) Tomorrow() GoTime
- func (d GoTime) WeekEnd() GoTime
- func (d GoTime) WeekStart() GoTime
- func (d GoTime) YearEnd() GoTime
- func (d GoTime) YearStart() GoTime
- func (d GoTime) Yesterday() GoTime
- type Time
Constants ¶
const ( // 本地时间格式 MsecLocalTimeFormat = "2006-01-02 15:04:05.000" SecLocalTimeFormat = "2006-01-02 15:04:05" MinuteLocalTimeFormat = "2006-01-02 15:04" HourLocalTimeFormat = "2006-01-02 15" DateLocalTimeFormat = "2006-01-02" MonthLocalTimeFormat = "2006-01" TimeLocalTimeFormat = "15:04:05" YearLocalTimeFormat = "2006" TimeLocation = "Asia/Shanghai" TimeLayout = "2006-01-02 15:04" // DateTimeStartFormat ... DateTimeStartFormat = "2006-01-02 00:00:00" // DateTimeEndFormat ... DateTimeEndFormat = "2006-01-02 23:59:59" )
const ( // 格式:2006-01-02 YYYY_MM_DD = "2006-01-02" // 格式:2006/01/02 DATE_DIR_PATTERN = "2006/01/02" YYYY_MM_DD_HH_MM_SS = "2006-01-02 15:04:05" )
Variables ¶
This section is empty.
Functions ¶
func CeilingTimeNow ¶ added in v0.0.8
CeilingTimeNow returns the current time from the range [now,now+100ms).
This is a faster alternative to time.Now().
func CountDaysOfMonth ¶ added in v0.0.9
func CurrentTimeLayout ¶ added in v0.0.2
func CurrentYear ¶ added in v0.0.2
func CurrentYear() string
func DateStrSubDays3 ¶ added in v0.0.9
DateStrSubDays3 end-start返回天数 日期格式: yyyy-mm-dd
func DateSubReturnDays ¶ added in v0.0.9
DateSubReturnDays end-start返回天数
func FirstDayOfCurrentYearAsString ¶ added in v0.0.9
func FirstDayOfCurrentYearAsString() string
FirstDayOfCurrentYearAsString 返回今年的第一天,格式为 2019-01-01
func FloorTimeNow ¶ added in v0.0.8
FloorTimeNow returns the current time from the range (now-100ms,now].
This is a faster alternative to time.Now().
func FormatDate ¶ added in v0.0.9
FormatDate 将日期转换成指定格式的字符串
func FormatDate1 ¶ added in v0.0.9
FormatDate1 日期转换成字符串 转换成: yyyymmdd
func FormatDate2 ¶ added in v0.0.9
FormatDate2 日期转换成字符串 转换成: yyyy/mm/dd
func FormatDate3 ¶ added in v0.0.9
FormatDate3 日期转换成字符串 转换成: yyyy-mm-dd
func FormatDate4 ¶ added in v0.0.9
FormatDate4 日期转换成字符串 转换成: yyyy-mm-dd mm:ss:ss
func GetDateAsDefaultStr ¶ added in v0.0.9
func GetDateAsDefaultStr() string
GetDateAsDefaultStr 获取当前日期,格式 yyyy-mm-dd
func GetEndtime ¶
func GetLastDayCurrentTime ¶
GetLastDayCurrentTime 获取offset天的现在时间:注意时区
func GetLastMonthStartAndEnd ¶ added in v0.0.9
GetLastMonthStartAndEnd 获取上月开始第一天和最后一天
func GetUtcDay0 ¶
GetUtcDay0 获取offset 0点时间
func ParseDate1 ¶ added in v0.0.9
ParseDate1 字符串转日期 字符串格式: yyyymmdd
func ParseDate2 ¶ added in v0.0.9
ParseDate2 字符串转日期 字符串格式: yyyy/mm/dd
func ParseDate3 ¶ added in v0.0.9
ParseDate3 字符串转日期 字符串格式: yyyy-mm-dd
func SecondsToTimesStr1 ¶ added in v0.0.9
SecondsToTimesStr1 将秒转化成 天时分 格式 最终格式: 1天10时5分
func SecondsToTimesStr2 ¶ added in v0.0.9
SecondsToTimesStr2 将秒转化成时间格式 最终格式: 00:00:00
func StringTimetoUnix ¶
StringTimetoUnix 给定字符串时间转换成本地时间戳
func Time2UnixNano ¶
func TimeStrSub ¶ added in v0.0.9
TimeStrSub 日期字符串相减 end-start 返回int
func UnixNano2Time ¶
Types ¶
type Date ¶ added in v0.0.7
type Date struct {
// contains filtered or unexported fields
}
Date ...
func NewDate ¶ added in v0.0.7
func NewDate(opts ...DateHandler) *Date
NewDate init Date struct if len(opts)=0, the base time is time.Now()
func (*Date) LastMonthEndDate ¶ added in v0.0.7
LastMonthEndDate ...
func (*Date) LastMonthEndDateTime ¶ added in v0.0.7
LastMonthEndDateTime ...
func (*Date) LastMonthStartDate ¶ added in v0.0.7
LastMonthStartDate ...
func (*Date) LastMonthStartDateTime ¶ added in v0.0.7
LastMonthStartDateTime ...
func (*Date) LastWeekEndDate ¶ added in v0.0.7
LastWeekEndDate ...
func (*Date) LastWeekEndDateTime ¶ added in v0.0.7
LastWeekEndDateTime ...
func (*Date) LastWeekStartDate ¶ added in v0.0.7
LastWeekStartDate ...
func (*Date) LastWeekStartDateTime ¶ added in v0.0.7
LastWeekStartDateTime ...
func (*Date) LastYearEndDate ¶ added in v0.0.7
LastYearEndDate ...
func (*Date) LastYearEndDateTime ¶ added in v0.0.7
LastYearEndDateTime ...
func (*Date) LastYearStartDate ¶ added in v0.0.7
LastYearStartDate ...
func (*Date) LastYearStartDateTime ¶ added in v0.0.7
LastYearStartDateTime ...
func (*Date) MonthStartDate ¶ added in v0.0.7
MonthStartDate ...
func (*Date) MonthStartDateTime ¶ added in v0.0.7
MonthStartDateTime ...
func (*Date) TodayDateTime ¶ added in v0.0.7
TodayDateTime ...
func (*Date) TodayEndDateTime ¶ added in v0.0.7
TodayEndDateTime ...
func (*Date) TodayStartDateTime ¶ added in v0.0.7
TodayStartDateTime ...
func (*Date) TomorrowEndDateTime ¶ added in v0.0.7
TomorrowEndDateTime ...
func (*Date) TomorrowStartDateTime ¶ added in v0.0.7
TomorrowStartDateTime ...
func (*Date) WeekStartDate ¶ added in v0.0.7
WeekStartDate ...
func (*Date) YearStartDate ¶ added in v0.0.7
YearStartDate ...
func (*Date) YearStartDateTime ¶ added in v0.0.7
YearStartDateTime ...
func (*Date) YesterdayDate ¶ added in v0.0.7
YesterdayDate ...
func (*Date) YesterdayEndDateTime ¶ added in v0.0.7
YesterdayEndDateTime ...
func (*Date) YesterdayStartDateTime ¶ added in v0.0.7
YesterdayStartDateTime ...
type DateHandler ¶ added in v0.0.7
type DateHandler func(d *Date)
DateHandler ...
func BindDate ¶ added in v0.0.7
func BindDate(dateStr string) DateHandler
func BindDateTime ¶ added in v0.0.7
func BindDateTime(datetimeStr string) DateHandler
func BindTime ¶ added in v0.0.7
func BindTime(dateObj time.Time) DateHandler
BindTime bind time.Time type as base time
type GoTime ¶ added in v0.0.8
func NewWithDateString ¶ added in v0.0.8
func NewWithDateTimeString ¶ added in v0.0.8
func NewWithTime ¶ added in v0.0.8
func (GoTime) FormatDateString ¶ added in v0.0.8
FormatDateString
func (GoTime) FormatDateTimeEndString ¶ added in v0.0.8
FormatDateTimeEndString
func (GoTime) FormatDateTimeStartString ¶ added in v0.0.8
FormatDateTimeStartString
func (GoTime) FormatDateTimeString ¶ added in v0.0.8
FormatDateTimeString
func (GoTime) LastMonthStart ¶ added in v0.0.8
LastMonthStart
func (GoTime) LastWeekStart ¶ added in v0.0.8
LastWeekStart ...
func (GoTime) NextMonthAfterStart ¶ added in v0.0.8
NextMonthAfterStart
func (GoTime) NextMonthStart ¶ added in v0.0.8
NextMonthStart
func (GoTime) NextWeekStart ¶ added in v0.0.8
NextWeekStart ...
func (GoTime) NextYearAfterStart ¶ added in v0.0.8
NextYearAfterStart