Documentation
¶
Overview ¶
Package timeutil provides centralized timezone handling for the application. Call LoadLocation once during initialization to set the canonical timezone, then use Now() and Location() throughout business logic instead of time.Now() and time.Local.
Index ¶
- func FormatDate(t time.Time) string
- func InLoc(t time.Time) time.Time
- func LoadLocation(tzName string) error
- func Location() *time.Location
- func LocationName() string
- func Now() time.Time
- func ParseDate(s string) (time.Time, error)
- func TodayEnd() time.Time
- func TodayStart() time.Time
- func UnixMilli(t time.Time) int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDate ¶
FormatDate formats a time as "2006-01-02" in the application timezone.
func LoadLocation ¶
LoadLocation loads the timezone by name (e.g., "Asia/Shanghai", "UTC"). Must be called once at startup before any other function in this package.
func Location ¶
Location returns the canonical application timezone. Falls back to time.Local if LoadLocation was never called.
func Now ¶
Now returns the current time in the application timezone. Falls back to time.Now() if LoadLocation was never called.
func TodayStart ¶
TodayStart returns the start of today (00:00:00) in the application timezone.
Types ¶
This section is empty.