tool

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchLocation

func FetchLocation() (string, error)

fetchLocation makes an API request to https://ipapi.co and returns location data.

func GetLocalTZ

func GetLocalTZ(localTZOverride string) (*time.Location, error)

GetLocalTZ tries to load a time.Location by name, or returns the system's local time zone. If both fail, returns an error.

func WhoAmI

func WhoAmI() (string, error)

func WorldTime

func WorldTime() (string, error)

Types

type LocationData

type LocationData struct {
	IP          string  `json:"ip"`
	Country     string  `json:"country_name"`
	CountryCode string  `json:"country_code"`
	Region      string  `json:"region"`
	City        string  `json:"city"`
	Latitude    float64 `json:"latitude"`
	Longitude   float64 `json:"longitude"`
	TimeZone    string  `json:"timezone"`
	Org         string  `json:"org"`
	ASN         string  `json:"asn"`
}

type TimeConversionResult

type TimeConversionResult struct {
	Source         TimeResult `json:"source_timezone"`
	Target         TimeResult `json:"target_timezone"`
	TimeDifference string     `json:"time_difference"`
}

func ConvertTime

func ConvertTime(sourceTz, timeStr, targetTz string) (TimeConversionResult, error)

func (TimeConversionResult) String

func (t TimeConversionResult) String() string

type TimeResult

type TimeResult struct {
	Timezone string `json:"timezone"`
	Datetime string `json:"datetime"`
	IsDST    bool   `json:"is_dst"`
}

func GetCurrentTime

func GetCurrentTime(timezoneName string) (*TimeResult, error)

func (TimeResult) String

func (t TimeResult) String() string

Jump to

Keyboard shortcuts

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