Documentation
¶
Overview ¶
Package convert provides utility functions for numeric conversions. It includes functions to convert integer values representing seconds into time.Duration and to convert values of various numeric types to int64. The functions are designed to be simple, ensuring that the project has a straightforward mechanism for numeric conversions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyToInt64 ¶
AnyToInt64 converts various numeric types to int64. It supports int64, float64, int, and uint types. If the conversion is unsupported, it returns an error indicating the input value's type.
Parameters:
- number: A value of any type to be converted to int64.
Returns:
- int64: The converted value if successful.
- error: An error if the conversion is not possible.
func IntegerToSeconds ¶
func IntegerToSeconds[T constraints.Integer](seconds T) time.Duration
IntegerToSeconds converts an integer representing seconds into a time.Duration. It multiplies the provided integer by time.Second.
Parameters:
- seconds: An integer value representing seconds.
Returns:
- time.Duration: The equivalent duration in seconds.
Types ¶
This section is empty.