aoc

package
v0.0.0-...-ca060dc Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URL     = "https://adventofcode.com/"
	Favicon = URL + "favicon.png"
)
View Source
const TotalDays = 25

Variables

View Source
var Client = http.Client{
	Timeout: 5 * time.Second,
}
View Source
var DayDuration = 24 * time.Hour

DayDuration is one day, or 24 hours.

View Source
var EST = time.FixedZone("Eastern Time", int((-5 * time.Hour).Seconds()))

EST is the timezone for Eastern Time (no DST).

Functions

func UntilMidnightEST

func UntilMidnightEST(t time.Time) time.Duration

Types

type DayCompletedParts

type DayCompletedParts [2]*time.Time

func (DayCompletedParts) Completed

func (d DayCompletedParts) Completed() bool

type DaysCompleted

type DaysCompleted []DayCompletedParts

Days start from 0, so 0-24

func (DaysCompleted) GetDay

func (d DaysCompleted) GetDay(day int) (DayCompletedParts, bool)

func (DaysCompleted) Total

func (d DaysCompleted) Total() (total int)

func (*DaysCompleted) UnmarshalJSON

func (d *DaysCompleted) UnmarshalJSON(b []byte) error

type Leaderboard

type Leaderboard struct {
	OwnerID int64  `json:"owner_id"`
	Event   string `json:"event"`

	Members map[int64]LeaderboardMember `json:"members"`
}

func (Leaderboard) SortMemberScores

func (l Leaderboard) SortMemberScores() []LeaderboardMember

Highest to lowest

type LeaderboardMember

type LeaderboardMember struct {
	ID            int64         `json:"id"`
	Name          string        `json:"name"`
	LocalScore    int64         `json:"local_score"`
	Stars         int64         `json:"stars"`
	DaysCompleted DaysCompleted `json:"completion_day_level"`
}

type Session

type Session struct {
	Token string
	Year  int

	// xxxxxx-xxxxxxxx
	Code string
}

func New

func New(year int, leaderboardCode string) (*Session, error)

func (*Session) CalculateLatestDay

func (s *Session) CalculateLatestDay() int

Range 1-25, 0 is not started/in the future

func (*Session) GetLatestDay

func (s *Session) GetLatestDay() (int, error)

func (*Session) GetLeaderboard

func (s *Session) GetLeaderboard() (*Leaderboard, error)

func (*Session) ID

func (s *Session) ID() string

ID returns the first part of the leaderboard code.

func (*Session) LeaderboardURL

func (s *Session) LeaderboardURL() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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