truckstop/broker/job.go

50 lines
803 B
Go

package broker
import (
"fmt"
"time"
)
type Job struct {
ID string
Pickup JobLocation
Dropoff JobLocation
Weight int
Miles int
Meta string
}
type JobLocation struct {
Date time.Time
City string
State string
}
func (j Job) String() string {
return fmt.Sprintf(
`%s => %s (%d miles), Weight:%d, Notes:%s`,
j.Pickup.String(),
j.Dropoff.String(),
j.Miles,
j.Weight,
j.Meta,
)
}
func (j JobLocation) String() string {
return fmt.Sprintf("%s, %s @ %s", j.City, j.State, j.Date.Format("Monday Jan 02"))
}
func (j Job) FormatMultilineText() string {
return fmt.Sprintf(
"--- %s => %s ---\nPickup: %s\nDropoff: %s\nNotes: %d lbs, %d miles, %s",
j.Pickup.State,
j.Dropoff.State,
j.Pickup.String(),
j.Dropoff.String(),
j.Weight,
j.Miles,
j.Meta,
)
}