convert

package
v0.0.0-...-2dd087d Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 3 Imported by: 0

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

func AnyToInt64[T any](number T) (int64, error)

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.

Jump to

Keyboard shortcuts

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