utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertTimezone

func ConvertTimezone(sourceTz, destTz string, ts time.Time) (time.Time, error)

ConvertTimezone converts a given timestamp from a source timezone to a destination timezone, returning the corresponding time in the destination timezone.

It automatically handles daylight saving time (DST) transitions based on IANA timezone data.

Parameters:

  • sourceTz: IANA timezone name for the source timezone (e.g., "America/New_York").
  • destTz: IANA timezone name for the destination timezone (e.g., "Europe/London").
  • ts: Time to convert (can be in any location).

Returns:

  • Converted timestamp in destination timezone.
  • Error if source or destination timezone is invalid.

Example usage:

converted, err := ConvertTimezone("America/New_York", "Europe/London", time.Now())
if err != nil {
    log.Fatal(err)
}
fmt.Println("Converted time:", converted)

func GetCurrentDateTime

func GetCurrentDateTime() string

GetCurrentDateTime returns the current date and time formatted according to time.DateTime. Note: time.DateTime is not a valid format and should be replaced with a specific format string like time.RFC3339 or "2006-01-02 15:04:05".

Returns:

  • string: The current date and time as a formatted string.

func GetCurrentEpochTime

func GetCurrentEpochTime() int64

GetCurrentEpochTime returns the current time as a Unix epoch timestamp in seconds.

Returns:

  • int64: The current time in seconds since January 1, 1970 UTC.

func GetCurrentEpochTimeMillis

func GetCurrentEpochTimeMillis() int64

GetCurrentEpochTimeMillis returns the current time as a Unix epoch timestamp in milliseconds.

Returns:

  • int64: The current time in milliseconds since January 1, 1970 UTC.

Types

This section is empty.

Directories

Path Synopsis
Package ansi allows for advanced terminal text manipulation.
Package ansi allows for advanced terminal text manipulation.
html_utils.go
html_utils.go
Package i18n provides a foundational implementation of a translation service using the Go x/text package.
Package i18n provides a foundational implementation of a translation service using the Go x/text package.
Package rest provides the HTTP and REST related utilities for the application.
Package rest provides the HTTP and REST related utilities for the application.
apiresponse
Package apiresponse contains all the data models that are expected to be used by the application for core workflows.
Package apiresponse contains all the data models that are expected to be used by the application for core workflows.
httpstub
Package httpstub provides a mechanism to create and manage HTTP stubs for testing, development, and other scenarios where controlling outgoing HTTP responses is beneficial.
Package httpstub provides a mechanism to create and manage HTTP stubs for testing, development, and other scenarios where controlling outgoing HTTP responses is beneficial.
LRU provides a fast, production‑grade Least Recently Used cache implementation.
LRU provides a fast, production‑grade Least Recently Used cache implementation.
testutil

Jump to

Keyboard shortcuts

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