diff --git a/server/server.go b/server/server.go index ead52aa..4d1caad 100644 --- a/server/server.go +++ b/server/server.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "text/template" + "time" "git.ctrlz.es/mgdelacroix/birthdaybot/model" "git.ctrlz.es/mgdelacroix/birthdaybot/notification" @@ -94,6 +95,12 @@ func New(options ...Option) (*Server, error) { if err != nil { return nil, fmt.Errorf("cannot parse template file %q: %w", srv.Config.Birthdays.Template, err) } + + srv.tmpl.Funcs(template.FuncMap{ + "GetYearsOld": func(yearOfBirth int) int { + return time.Now().Year() - yearOfBirth + }, + }) } return srv, nil