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) iter.Seq[Milestone]
- func RemindPtrs(entries []*Entry, periods []Period, current time.Time) iter.Seq[*Milestone]
- func ToString(t time.Time) string
- func ToStringWithWeekDay(t time.Time) string
- func Today(clock date_util.Clock) time.Time
- type Entry
- type Milestone
- type Period
- type Store
- type SystemStore
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 ¶
Remind returns all upcoming Milestones for the specified entries and periods starting at the date specified by current. Remind returns Milestone instances in chronological order.
func RemindPtrs ¶
RemindPtrs works like Remind except that it returns Milestone pointers.
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
EntryPtr *Entry
// The date of the milestone day
Date time.Time
// The age of the person on this milestone 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.