Documentation
¶
Index ¶
- Constants
- func AddBusinessDays(t time.Time, days int) time.Time
- func Age(birthDate time.Time) int
- func BusinessDaysBetween(start, end time.Time) int
- func DaysBetween(start, end time.Time) int
- func DaysInMonth(year int, month time.Month) int
- func EndOfMonth(t time.Time) time.Time
- func EndOfQuarter(t time.Time) time.Time
- func EndOfWeek(t time.Time) time.Time
- func EndOfYear(t time.Time) time.Time
- func FormatDuration(d time.Duration) string
- func FromUnixMillis(millis int64) time.Time
- func FromUnixTimestamp(timestamp int64) time.Time
- func GetQuarter(t time.Time) int
- func InTimeRange(t, start, end time.Time) bool
- func IsFuture(t time.Time) bool
- func IsLeapYear(year int) bool
- func IsPast(t time.Time) bool
- func IsToday(t time.Time) bool
- func IsTomorrow(t time.Time) bool
- func IsWeekday(t time.Time) bool
- func IsWeekend(t time.Time) bool
- func IsYesterday(t time.Time) bool
- func Max(t1, t2 time.Time) time.Time
- func Min(t1, t2 time.Time) time.Time
- func Now() time.Time
- func NowUTC() time.Time
- func ParseDate(dateStr string) (time.Time, error)
- func Round(t time.Time, d time.Duration) time.Time
- func StartOfMonth(t time.Time) time.Time
- func StartOfQuarter(t time.Time) time.Time
- func StartOfWeek(t time.Time) time.Time
- func StartOfYear(t time.Time) time.Time
- func TimeAgo(t time.Time) string
- func TimeUntil(t time.Time) string
- func ToUnixMillis(t time.Time) int64
- func ToUnixTimestamp(t time.Time) int64
- func Today() time.Time
- func TodayUTC() time.Time
- func Tomorrow() time.Time
- func Truncate(t time.Time, d time.Duration) time.Time
- func Yesterday() time.Time
Constants ¶
const ( DayInSeconds = 24 * 60 * 60 WeekInSeconds = 7 * DayInSeconds MonthInSeconds = 30 * DayInSeconds YearInSeconds = 365 * DayInSeconds DayInMinutes = 24 * 60 WeekInMinutes = 7 * DayInMinutes MonthInMinutes = 30 * DayInMinutes YearInMinutes = 365 * DayInMinutes )
Common time constants
const ( DateFormat = "2006-01-02" TimeFormat = "15:04:05" DateTimeFormat = "2006-01-02 15:04:05" ISO8601Format = "2006-01-02T15:04:05Z07:00" RFC3339Format = time.RFC3339 TimestampFormat = "20060102150405" HumanDateFormat = "January 2, 2006" HumanTimeFormat = "3:04 PM" HumanDateTimeFormat = "January 2, 2006 at 3:04 PM" )
Common time formats
Variables ¶
This section is empty.
Functions ¶
func AddBusinessDays ¶
AddBusinessDays adds business days to a date (skipping weekends)
func BusinessDaysBetween ¶
BusinessDaysBetween calculates the number of business days between two dates
func DaysBetween ¶
DaysBetween calculates the number of days between two dates
func DaysInMonth ¶
DaysInMonth returns the number of days in the given month and year
func EndOfMonth ¶
EndOfMonth returns the end of the month for the given time
func EndOfQuarter ¶
EndOfQuarter returns the end of the quarter for the given time
func FormatDuration ¶
FormatDuration formats a duration in human-readable format
func FromUnixMillis ¶
FromUnixMillis converts Unix timestamp in milliseconds to time
func FromUnixTimestamp ¶
FromUnixTimestamp converts Unix timestamp to time
func GetQuarter ¶
GetQuarter returns the quarter (1-4) for the given time
func InTimeRange ¶
InTimeRange checks if a time is within the given range (inclusive)
func IsYesterday ¶
IsYesterday checks if the given time is yesterday
func StartOfMonth ¶
StartOfMonth returns the start of the month for the given time
func StartOfQuarter ¶
StartOfQuarter returns the start of the quarter for the given time
func StartOfWeek ¶
StartOfWeek returns the start of the week (Monday) for the given time
func StartOfYear ¶
StartOfYear returns the start of the year for the given time
func ToUnixMillis ¶
ToUnixMillis converts time to Unix timestamp in milliseconds
func ToUnixTimestamp ¶
ToUnixTimestamp converts time to Unix timestamp
Types ¶
This section is empty.