util

package
v0.0.0-...-3b42a61 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateDeliveryTime

func CalculateDeliveryTime(deliveryEstimate time.Time) time.Duration

CalculateDeliveryTime returns the time until an estimated future date

func ExchangeRateGraph

func ExchangeRateGraph(client *client.Client, sourceCurrency, targetCurrency string)

ExchangeRateGraph prints an ASCII plot for the last 30 days of rates for a currency pair

func ParseTime

func ParseTime(timeStr string) time.Time

ParseTime is to normalise different time formats

func ValidCurrencyCode

func ValidCurrencyCode(code string) bool

Check that a currency code is a recognised ISO 4217 value and well formatted

Types

type ExchangeRateRecord

type ExchangeRateRecord struct {
	Rate   float64 `json:"rate,omitempty"`
	Source string  `json:"source,omitempty"`
	Target string  `json:"target,omitempty"`
	Time   string  `json:"time,omitempty"`
}

ExchangeRateRecord is the recorded exchange rate at a point in time

type RateHistory

type RateHistory struct {
	Entries []ExchangeRateRecord
}

RateHistory is a collection of rate records for a currency pair

func (*RateHistory) Rates

func (r *RateHistory) Rates() []float64

Rates returns all the number values for rate from a collection of entries

Jump to

Keyboard shortcuts

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