Documentation ¶
Overview ¶
Package birthday contains routines for tracking birthdays.
Index ¶
- Variables
- func HasYear(t time.Time) bool
- func Parse(s string) (parsed time.Time, err error)
- func Query(query string) func(entry Entry) bool
- func Read(r io.Reader, consumer consume2.Consumer[Entry]) error
- func ReadFile(filename string, consumer consume2.Consumer[Entry]) error
- func Remind(entries []Entry, periods []Period, current time.Time, ...)
- func ToString(t time.Time) string
- func ToStringWithWeekDay(t time.Time) string
- func Today() time.Time
- type Entry
- type Milestone
- type Period
Constants ¶
This section is empty.
Variables ¶
var ( // Currently yearly, 100 months, 100 weeks, 1000 days. DefaultPeriods = []Period{ {Years: 1}, {Months: 100}, {Weeks: 100}, {Days: 1000}, } )
Functions ¶
func Parse ¶
Parse converts s to a time in UTC. s must be of form MM/dd/yyyy or MM/dd. If s is of form MM/dd, the year of returned time is 0. s must be a valid date as no normalizing is done. Invalid dates like '08/32/2006' return an error.
func Query ¶
Query returns a function that returns true if the Entry instance passed to it matches query.
func Remind ¶
func Remind( entries []Entry, periods []Period, current time.Time, consumer consume2.Consumer[Milestone])
Remind sends an infinite stream of Milestone instances to consumer for the specified entries and periods starting at the date specified by current. Remind sends Milestone instances to consumer in chronological order.
func ToStringWithWeekDay ¶
ToStringWithWeekDay works like ToString but adds weekday. ToStringWithWeekDay returns a string such as 'Mon 01/02/2006'. ToStringWithWeekDay panics if t falls before 1 Jan 0001.
Types ¶
type Entry ¶
Entry represents a single entry in the birthday database
func EntriesSortedByName ¶
EntriesSortedByName returns entries sorted by name while leaving the original entries slice unchanged.
type Milestone ¶
type Milestone struct { // The person having the milestone Entry // The date of the milestone day Date time.Time // How many days in the future this milestone day is. DaysAway int // The age of the person on this mileestone day. Age Period // If true, age is unknown AgeUnknown bool }
Milestone represents a milestone day.
type Period ¶
type Period struct { Years int Months int Weeks int Days int // If true, Multiply normalizes. Normalize bool }
Period represents a period of time
func (Period) Diff ¶
Diff returns the number of this period between end and start rounded down. Diff panics if this period is not valid.
func (Period) Less ¶
Less orders Periods. Less orders first by Days, then by Weeks, then by Months, and finally by Years.