Documentation
¶
Index ¶
- func DaysToSeconds(days int) int64
- func IsAtLeastAge(dob int64, age int) bool
- func MonthsAgoUnix(months int) int64
- func MonthsAgoUnixPointer(months int) *int64
- func MonthsFromNowUnix(months int) int64
- func NowUnix() int64
- func NowUnixPointer() *int64
- func ParseTimeValue(value any) (time.Time, error)
- func SecondsPerYear() int64
- func YearsAgoUnix(years int) int64
- func YearsAgoUnixPointer(years int) *int64
- func YearsFromNowUnix(years int) int64
- func YearsFromNowUnixPointer(years int) *int64
- func YearsToSeconds(years int) int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DaysToSeconds ¶
DaysToSeconds converts a number of days into the equivalent number of seconds.
func IsAtLeastAge ¶
IsAtLeastAge determines if a given date of birth (in Unix timestamp format) represents a person who is at least the specified age in years. The function compares the date of birth against a timestamp calculated as the current time minus the specified age in years.
func MonthsAgoUnix ¶
MonthsAgoUnix returns the Unix timestamp corresponding to the current time minus a specified number of months. The function uses the AddDate method to subtract the specified number of months.
func MonthsAgoUnixPointer ¶
MonthsAgoUnixPointer returns a pointer to the Unix timestamp corresponding to the current time minus a specified number of months. The function uses the AddDate method to subtract the specified number of months.
func MonthsFromNowUnix ¶
MonthsFromNowUnix returns the Unix timestamp corresponding to the current time plus a specified number of months. The function uses the AddDate method to add the specified number of months.
func NowUnix ¶
func NowUnix() int64
NowUnix returns the current time as a Unix timestamp. The Unix timestamp represents the number of seconds elapsed since January 1, 1970 UTC.
func NowUnixPointer ¶
func NowUnixPointer() *int64
NowUnixPointer returns a pointer to the current Unix timestamp. This is useful for cases where a pointer to the timestamp is needed.
func ParseTimeValue ¶
ParseTimeValue parses a given value into a time.Time object. Supported input types: - string: Parses the string as an RFC3339 formatted timestamp. - time.Time: Returns the input as-is. - int64: Treats the value as a Unix timestamp and converts it to time.Time. Returns an error if the input type is unsupported.
func SecondsPerYear ¶
func SecondsPerYear() int64
SecondsPerYear returns the number of seconds in a year. It assumes a year has 365 days and does not account for leap years.
func YearsAgoUnix ¶
YearsAgoUnix returns the Unix timestamp corresponding to the current time minus a specified number of years. The function uses the AddDate method to subtract the specified number of years.
func YearsAgoUnixPointer ¶
YearsAgoUnixPointer returns a pointer to the Unix timestamp corresponding to the current time minus a specified number of years. The function uses the AddDate method to subtract the specified number of years.
func YearsFromNowUnix ¶
YearsFromNowUnix returns the Unix timestamp corresponding to the current time plus a specified number of years. The function uses the AddDate method to add the specified number of years.
func YearsFromNowUnixPointer ¶
YearsFromNowUnixPointer returns a pointer to the Unix timestamp corresponding to the current time plus a specified number of years. The function uses the AddDate method to add the specified number of years.
func YearsToSeconds ¶
YearsToSeconds converts a number of years into the equivalent number of seconds. It assumes a year has 365 days and does not account for leap years.
Types ¶
This section is empty.