timeanddate

package module
v0.0.0-...-9f93050 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 10 Imported by: 0

README

timeanddate

scrapes TimeAndDate.com

working:

2023/10/23 13:35:42 Country:    Germany
2023/10/23 13:35:42 State:      Bavaria (BY)
2023/10/23 13:35:42 Position:   Lat: 49.97; Lon: 9.15
2023/10/23 13:35:42 Elevation:  131 meters
2023/10/23 13:35:42 Currency:   Euro (EUR)
2023/10/23 13:35:42 Language:   German
2023/10/23 13:35:42 AccessCode: +49
2023/10/23 13:35:42 ---
2023/10/23 13:35:42 Time:       13:35:42
2023/10/23 13:35:42 Date:       Monday, 23, October 2023
2023/10/23 13:35:42   =>>       Mon Oct 23 13:35:42 UTC 2023
TODO:
- more stuff
	- Weather
	- Time Zone
	- DST Changes
	- Sun & Moon 
- only works for german cities as format is different for other countries (yay)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = New()
View Source
var (
	ErrDeserialize = errors.New("Failed to deserialize")
)
View Source
var (
	ErrInvalidResponse = errors.New("Received invalid response")
)

Functions

func UnmarshalMonth

func UnmarshalMonth(s string) time.Month

func UnmarshalWeekday

func UnmarshalWeekday(s string) time.Weekday

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New() *Client

func (*Client) Get

func (c *Client) Get(path string) (r *TimeAndDate, err error)

func (*Client) Search

func (c *Client) Search(query string) (r []SearchResult, err error)

https://www.timeanddate.com/scripts/completion.php?query=!!QUERY¡¡&xd=1&mode=ci

type Currency

type Currency struct {
	Name string
	Code string
}

func (*Currency) String

func (s *Currency) String() string

func (*Currency) UnmarshalText

func (c *Currency) UnmarshalText(d []byte) error

Euro (EUR)

type Date

type Date struct {
	Weekday   time.Weekday
	Month     time.Month
	Day, Year int
}

func (*Date) String

func (t *Date) String() string

func (*Date) UnmarshalText

func (t *Date) UnmarshalText(d []byte) error

type Position

type Position struct {
	Latitude  float32
	Longitude float32
}

func (*Position) String

func (c *Position) String() string

func (*Position) UnmarshalText

func (c *Position) UnmarshalText(d []byte) error

e.g. 49°58'N / 9°09'E

type SearchResult

type SearchResult struct {
	Path        string // e.g. /worldclock/@2830841
	Unused1     string // e.g. 5
	CountryCode string // e.g. de
	Unused2     string // e.g. b
	City        string // e.g. Bezirk Spandau (fifth-order administrative division)

	State       string // e.g. Berlin
	Country     string // e.g. Germany
	CountryFlag string // e.g. //c.tadst.com/gfx/n/fl/16/de.png
	Unused3     string // e.g. ""
	Unused4     string // e.g. ""
	Unused5     string // e.g. "p"
	Unused6     string // e.g. ""
}
func Search(query string) (r []SearchResult, err error)

performs search with DefaultClient

type State

type State struct {
	Name string
	Code string
}

func (*State) String

func (s *State) String() string

func (*State) UnmarshalText

func (c *State) UnmarshalText(d []byte) error

Bavaria (BY)

type Time

type Time struct {
	Hours, Minutes, Seconds int
}

func (*Time) String

func (t *Time) String() string

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(d []byte) error

type TimeAndDate

type TimeAndDate struct {
	Country    string    // e.g. Germany
	State      *State    // e.g. Bavaria (BY)
	Province   *State    // e.g. Bavaria (BY)
	Position   *Position // e.g. 49°58'N / 9°09'E
	Elevation  int       // in meters
	Currency   *Currency // e.g. Euro (EUR)
	Languages  []string  // e.g. German
	AccessCode string    //  e.g. +49

	Time *Time // e.g. 12:54:53
	Date *Date // e.g. Monday, 23 October 2023
}

func Get

func Get(path string) (r *TimeAndDate, err error)

func (*TimeAndDate) TimeTime

func (t *TimeAndDate) TimeTime() time.Time

returns time in UTC because easier // TODO: get data from time/zone/

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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