datetime

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareTime

func CompareTime(timeA, timeB, timeATimezone, timeBTimezone string) (int, error)

CompareTime compares two time strings and returns:

  • -1 if timeA is before timeB
  • 0 if timeA is equal to timeB
  • 1 if timeA is after timeB

func ConvertTime

func ConvertTime(inputTime, inputTimezone, outputTimezone, format string) (output string, err error)

ConvertTime converts a given time string from one timezone to another. If inputTimezone is empty, UTC is used as the default.

func CurrentTime

func CurrentTime(timezone, format string) (output string, err error)

CurrentTime returns the current time in the specified timezone and format.

func GetDefaultFormat

func GetDefaultFormat() string

GetDefaultFormat returns the default format layout string.

func GetDefaultTimezone

func GetDefaultTimezone() string

GetDefaultTimezone returns the default timezone string.

func GetFormats

func GetFormats() []string

GetFormats returns a slice of all supported format names.

func RelativeTime

func RelativeTime(inputTime, relativeTime, timezone, format string) (output string, err error)

RelativeTime parses a relative time string (e.g., "2 hours ago") based on a reference time.

func TimeAdd

func TimeAdd(inputTime, duration, timezone, format string) (output string, err error)

TimeAdd adds a duration to a given time string and returns the result in the specified timezone and format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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