time

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndOfDay

func EndOfDay(t time.Time) time.Time

EndOfDay returns the last moment of the day 23:59:59.999999999 in the same location

func IsToday

func IsToday(t time.Time) bool

IsToday checks if a timestamp is today in the current local timezone Compares after StartOfDay and before StartOfDay + 24h Exact StartOfDay today is considered today Exact EndOfDay today is considered today

func IsTodayLoc

func IsTodayLoc(t time.Time, loc *time.Location) bool

IsTodayLoc checks if a timestamp is today in the specified time.Location Compares after StartOfDay and before StartOfDay + 24h Exact StartOfDay today is considered today Exact EndOfDay today is considered today

func IsTomorrow

func IsTomorrow(t time.Time) bool

IsTomorrow checks if a timestamp is tomorrow in the current local timezone Compares after StartOfDay + 24h and before StartOfDay + 48h Exact StartOfDay tomorrow is considered tomorrow Exact EndOfDay tomorrow is considered tomorrow

func IsTomorrowLoc

func IsTomorrowLoc(t time.Time, loc *time.Location) bool

IsTomorrowLoc checks if a timestamp is tomorrow in the specified time.Location Compares after StartOfDay + 24h and before StartOfDay + 48h Exact StartOfDay tomorrow is considered tomorrow Exact EndOfDay tomorrow is considered tomorrow

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration extends time.ParseDuration to support "d" (days) and "w" (weeks) Replaces d with 24h, w with 168h, then pass to time.ParseDuration Supports float values too

func StartOfDay

func StartOfDay(t time.Time) time.Time

StartOfDay returns the date at 00:00:00.000 in the same location

func TimeAgo

func TimeAgo(t time.Time) string

TimeAgo returns a human friendly relative time formatting <1m → "just now" =1m → "1 minute ago" <1h → "X minutes ago" <24h → "X hours ago" <48h → "yesterday" otherwise → "X days ago" Explore the options of using i18n in a future release

Types

This section is empty.

Jump to

Keyboard shortcuts

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