util

package
v0.0.0-...-f0a7105 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 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/Ho_Chi_Minh"
)

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 How many hours are there between the two days?

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 Get the date string within the interval (for example: 2023-05-23 - 2023-05-23) - this month

func GetCurrentMonthRangeTime

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

GetCurrentMonthRangeTime Get interval time - this month

func GetCurrentMonthRangeTimeString

func GetCurrentMonthRangeTimeString() (string, string)

GetCurrentMonthRangeTimeString Get the time string within the interval (for example: 2023-05-23 00:00:00 2023-05-23 23:59:59) - this month

func GetCurrentYearRangeDateString

func GetCurrentYearRangeDateString() (string, string)

GetCurrentYearRangeDateString Get the date string within the interval (for example: 2023-05-23 - 2023-05-23) - this year

func GetCurrentYearRangeTime

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

GetCurrentYearRangeTime Get interval time - this year

func GetCurrentYearRangeTimeString

func GetCurrentYearRangeTimeString() (string, string)

GetCurrentYearRangeTimeString Get the time string within the interval (for example: 2023-05-23 00:00:00 2023-05-23 23:59:59) - this year

func GetLastMonthRangeDateString

func GetLastMonthRangeDateString() (string, string)

GetLastMonthRangeDateString Get the date string within the interval (for example: 2023-05-23 - 2023-05-23) - last month

func GetLastMonthRangeTime

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

GetLastMonthRangeTime Get interval time - last month

func GetLastMonthRangeTimeString

func GetLastMonthRangeTimeString() (string, string)

GetLastMonthRangeTimeString Get the time string within the interval (for example: 2023-05-23 00:00:00 2023-05-23 23:59:59) - last month

func GetLastYearRangeDateString

func GetLastYearRangeDateString() (string, string)

GetLastYearRangeDateString Get the date string within the interval (for example: 2023-05-23 - 2023-05-23) - last year

func GetLastYearRangeTime

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

GetLastYearRangeTime Get interval time - last year

func GetLastYearRangeTimeString

func GetLastYearRangeTimeString() (string, string)

GetLastYearRangeTimeString Get the time string within the interval (for example: 2023-05-23 00:00:00 2023-05-23 23:59:59) - last year

func GetTodayRangeDateString

func GetTodayRangeDateString() (string, string)

GetTodayRangeDateString Get the date string within the interval (for example: 2023-05-23 - 2023-05-23) - today

func GetTodayRangeTime

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

GetTodayRangeTime Get interval time - today

func GetTodayRangeTimeString

func GetTodayRangeTimeString() (string, string)

GetTodayRangeTimeString Get the time string within the interval (for example: 2023-05-23 00:00:00 2023-05-23 23:59:59) - today

func GetYesterdayRangeDateString

func GetYesterdayRangeDateString() (string, string)

GetYesterdayRangeDateString Get the date string within the interval (for example: 2023-05-23 - 2023-05-23) - yesterday

func GetYesterdayRangeTime

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

GetYesterdayRangeTime Get interval time - yesterday

func GetYesterdayRangeTimeString

func GetYesterdayRangeTimeString() (string, string)

GetYesterdayRangeTimeString Get the time string within the interval (for example: 2023-05-23 00:00:00 2023-05-23 23:59:59) - yesterday

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 How many days are there between the two days?

func StringDateToTime

func StringDateToTime(str *string) *time.Time

StringDateToTime Date string -> time

func StringDifferenceDays

func StringDifferenceDays(startDate, endDate string) int

StringDifferenceDays How many days are there between the two days?

func StringTimeToTime

func StringTimeToTime(str *string) *time.Time

StringTimeToTime time string -> time

func StringToUnixMilliInt64Ptr

func StringToUnixMilliInt64Ptr(tm *string) *int64

StringToUnixMilliInt64Ptr string -> millisecond timestamp

func TimeDifferenceDays

func TimeDifferenceDays(startDate, endDate time.Time) int

TimeDifferenceDays How many days are there between the two days?

func TimeToDateString

func TimeToDateString(tm *time.Time) *string

TimeToDateString Time -> date string

func TimeToTimeString

func TimeToTimeString(tm *time.Time) *string

TimeToTimeString Time -> time string

func TimeToTimestamppb

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

TimeToTimestamppb time.Time -> timestamppb.Timestamp

func TimestamppbToTime

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

TimestamppbToTime timestamppb.Timestamp -> time.Time

func UnixMilliToStringPtr

func UnixMilliToStringPtr(tm *int64) *string

UnixMilliToStringPtr millisecond timestamp -> string

Types

This section is empty.

Jump to

Keyboard shortcuts

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