Documentation
¶
Index ¶
- func DaysBetween(nano1, nano2 int64) int
- func DaysBetweenShared(nano1, nano2 int64) int
- func FormatCompact(nano int64) string
- func FormatDate(value any) string
- func FormatDateTime(value any) string
- func FormatDateTimeShort(value any) string
- func FormatISO8601(nano int64) string
- func FormatTime(value any) string
- func GetTimeZoneOffset() int
- func IsFuture(nano int64) bool
- func IsPast(nano int64) bool
- func IsToday(nano int64) bool
- func LocalMinutesToUnixUTC(dateSec int64, localMinutes int, tz string) int64
- func MidnightUTC(unixSec int64) int64
- func Now() int64
- func ParseDate(dateStr string) (int64, error)
- func ParseDateTime(dateStr, timeStr string) (int64, error)
- func ParseTime(timeStr string) (int16, error)
- func SetTimeZoneOffset(hours int)
- func Weekday(unixSec int64) int
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DaysBetween ¶ added in v0.3.0
DaysBetween calculates the number of full days between two UnixNano timestamps.
func DaysBetweenShared ¶ added in v0.3.0
DaysBetweenShared is a shared helper function for calculating the number of full days between two timestamps.
func FormatCompact ¶ added in v0.4.0
FormatCompact formats a UnixNano timestamp into a compact string "YYYYMMDDHHmmss" (UTC). Useful for PDF metadata dates, file naming, and compact timestamps.
func FormatDate ¶ added in v0.3.0
FormatDate formats a value into a date string "YYYY-MM-DD" applying the timezone offset.
func FormatDateTime ¶ added in v0.3.0
FormatDateTime formats a value into a date-time string "YYYY-MM-DD HH:MM:SS" applying the timezone offset.
func FormatDateTimeShort ¶ added in v0.3.0
FormatDateTimeShort formats a value into a short date-time string "YYYY-MM-DD HH:MM".
func FormatISO8601 ¶ added in v0.3.9
FormatISO8601 formats a UnixNano timestamp into an ISO 8601 string (UTC). Format: "YYYY-MM-DDTHH:MM:SSZ"
func FormatTime ¶ added in v0.3.0
FormatTime formats a value into a time string "HH:MM:SS" applying the timezone offset.
func GetTimeZoneOffset ¶ added in v0.3.0
func GetTimeZoneOffset() int
GetTimeZoneOffset returns the current timezone offset in hours.
func IsToday ¶ added in v0.3.0
IsToday checks if the given UnixNano timestamp is today according to the current timezone offset.
func LocalMinutesToUnixUTC ¶ added in v0.5.0
LocalMinutesToUnixUTC converts minutes-from-midnight expressed in a local timezone into a UTC Unix timestamp in seconds for the given date. dateSec is a Unix timestamp in seconds (UTC) that identifies the target date. localMinutes is minutes elapsed since midnight in the local timezone. tz is an IANA timezone name (e.g. "America/New_York"); falls back to UTC if invalid.
func MidnightUTC ¶ added in v0.5.0
MidnightUTC returns the Unix timestamp in seconds for midnight UTC of the day that contains the given Unix timestamp in seconds.
func Now ¶ added in v0.3.0
func Now() int64
Now retrieves the current Unix timestamp in nanoseconds in UTC.
func ParseDate ¶ added in v0.3.0
ParseDate parses a date string ("YYYY-MM-DD") into a UnixNano timestamp (UTC).
func ParseDateTime ¶ added in v0.3.0
ParseDateTime combines date and time strings into a single UnixNano timestamp (UTC).
func SetTimeZoneOffset ¶ added in v0.3.0
func SetTimeZoneOffset(hours int)
SetTimeZoneOffset manually sets the timezone offset in hours.