util

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateLayout  = "2006-01-02"
	ClockLayout = "15:04:05"
	TimeLayout  = DateLayout + " " + ClockLayout

	DefaultTimeLocationName = "Asia/Shanghai"
)

Variables

View Source
var DefaultTimeLocation *time.Location
View Source
var ReferenceTimeValue time.Time = time.Date(2006, 1, 2, 15, 4, 5, 999999999, time.FixedZone("MST", -7*60*60))

Functions

func DayDifferenceHours

func DayDifferenceHours(startDate, endDate string) float64

DayDifferenceHours 两天之间相差了多少小时

func DaySecondsDifferenceHours

func DaySecondsDifferenceHours(startSecond, endSecond int64) float64

func DayTimeDifferenceHours

func DayTimeDifferenceHours(startDate, endDate time.Time) float64

func DurationHMS

func DurationHMS(d time.Duration) (int, int, int)

DurationHMS Extracts the hours, minutes, and seconds from the given duration.

func FormatTimer

func FormatTimer(d time.Duration) string

FormatTimer Formats the given duration in a colon-separated timer format in the form [HH:]MM:SS.

func FormatTimerf

func FormatTimerf(format string, d time.Duration) string

FormatTimerf Formats the given duration using the given format string. The string follows the same formatting rules as described in the fmt package, and will receive three integer arguments: hours, minutes, and seconds.

func GetCurrentMonthRangeDateString

func GetCurrentMonthRangeDateString() (string, string)

GetCurrentMonthRangeDateString 获取区间时间内的日期字符串(比如:2023-05-23 2023-05-23) - 本月

func GetCurrentMonthRangeTime

func GetCurrentMonthRangeTime() (time.Time, time.Time)

GetCurrentMonthRangeTime 获取区间时间 - 本月

func GetCurrentMonthRangeTimeString

func GetCurrentMonthRangeTimeString() (string, string)

GetCurrentMonthRangeTimeString 获取区间时间内的时间字符串(比如:2023-05-23 00:00:00 2023-05-23 23:59:59) - 本月

func GetCurrentYearRangeDateString

func GetCurrentYearRangeDateString() (string, string)

GetCurrentYearRangeDateString 获取区间时间内的日期字符串(比如:2023-05-23 2023-05-23) - 今年

func GetCurrentYearRangeTime

func GetCurrentYearRangeTime() (time.Time, time.Time)

GetCurrentYearRangeTime 获取区间时间 - 今年

func GetCurrentYearRangeTimeString

func GetCurrentYearRangeTimeString() (string, string)

GetCurrentYearRangeTimeString 获取区间时间内的时间字符串(比如:2023-05-23 00:00:00 2023-05-23 23:59:59) - 今年

func GetLastMonthRangeDateString

func GetLastMonthRangeDateString() (string, string)

GetLastMonthRangeDateString 获取区间时间内的日期字符串(比如:2023-05-23 2023-05-23) - 上个月

func GetLastMonthRangeTime

func GetLastMonthRangeTime() (time.Time, time.Time)

GetLastMonthRangeTime 获取区间时间 - 上个月

func GetLastMonthRangeTimeString

func GetLastMonthRangeTimeString() (string, string)

GetLastMonthRangeTimeString 获取区间时间内的时间字符串(比如:2023-05-23 00:00:00 2023-05-23 23:59:59) - 上个月

func GetLastYearRangeDateString

func GetLastYearRangeDateString() (string, string)

GetLastYearRangeDateString 获取区间时间内的日期字符串(比如:2023-05-23 2023-05-23) - 去年

func GetLastYearRangeTime

func GetLastYearRangeTime() (time.Time, time.Time)

GetLastYearRangeTime 获取区间时间 - 去年

func GetLastYearRangeTimeString

func GetLastYearRangeTimeString() (string, string)

GetLastYearRangeTimeString 获取区间时间内的时间字符串(比如:2023-05-23 00:00:00 2023-05-23 23:59:59) - 去年

func GetTodayRangeDateString

func GetTodayRangeDateString() (string, string)

GetTodayRangeDateString 获取区间时间内的日期字符串(比如:2023-05-23 2023-05-23) - 今天

func GetTodayRangeTime

func GetTodayRangeTime() (time.Time, time.Time)

GetTodayRangeTime 获取区间时间 - 今天

func GetTodayRangeTimeString

func GetTodayRangeTimeString() (string, string)

GetTodayRangeTimeString 获取区间时间内的时间字符串(比如:2023-05-23 00:00:00 2023-05-23 23:59:59) - 今天

func GetYesterdayRangeDateString

func GetYesterdayRangeDateString() (string, string)

GetYesterdayRangeDateString 获取区间时间内的日期字符串(比如:2023-05-23 2023-05-23) - 昨天

func GetYesterdayRangeTime

func GetYesterdayRangeTime() (time.Time, time.Time)

GetYesterdayRangeTime 获取区间时间 - 昨天

func GetYesterdayRangeTimeString

func GetYesterdayRangeTimeString() (string, string)

GetYesterdayRangeTimeString 获取区间时间内的时间字符串(比如:2023-05-23 00:00:00 2023-05-23 23:59:59) - 昨天

func ReferenceTime

func ReferenceTime() time.Time

ReferenceTime Return the standard Golang reference time (2006-01-02T15:04:05.999999999Z07:00)

func RefreshDefaultTimeLocation

func RefreshDefaultTimeLocation(name string)

func SecondsDifferenceDays

func SecondsDifferenceDays(startSecond, endSecond int64) int

SecondsDifferenceDays 两天之间相差了多少天

func StringDateToTime

func StringDateToTime(str *string) *time.Time

StringDateToTime 字符串 -> 时间

func StringDifferenceDays

func StringDifferenceDays(startDate, endDate string) int

StringDifferenceDays 两天之间相差了多少天

func StringTimeToTime

func StringTimeToTime(str *string) *time.Time

StringTimeToTime 时间字符串 -> 时间

func StringToUnixMilliInt64Ptr

func StringToUnixMilliInt64Ptr(tm *string) *int64

StringToUnixMilliInt64Ptr 字符串 -> 毫秒时间戳

func TimeDifferenceDays

func TimeDifferenceDays(startDate, endDate time.Time) int

TimeDifferenceDays 两天之间相差了多少天

func TimeToDateString

func TimeToDateString(tm *time.Time) *string

TimeToDateString 时间 -> 日期字符串

func TimeToTimeString

func TimeToTimeString(tm *time.Time) *string

TimeToTimeString 时间 -> 时间字符串

func TimeToTimestamppb added in v1.1.10

func TimeToTimestamppb(tm *time.Time) *timestamppb.Timestamp

TimeToTimestamppb time.Time -> timestamppb.Timestamp

func TimestamppbToTime added in v1.1.10

func TimestamppbToTime(tm *timestamppb.Timestamp) *time.Time

TimestamppbToTime timestamppb.Timestamp -> time.Time

func UnixMilliToStringPtr

func UnixMilliToStringPtr(tm *int64) *string

UnixMilliToStringPtr 毫秒时间戳 -> 字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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