learned I didn't need git for external modules and different folders can have different mains

This commit is contained in:
2024-02-03 11:00:34 -05:00
parent 943191e9dd
commit 19b1581f10
37 changed files with 439 additions and 16 deletions

56
pkg/date/date.go Normal file
View File

@ -0,0 +1,56 @@
package calendar
import "errors"
// Date Struct
type Date struct {
year int
month int
day int
}
// Setter Methods
// SetYear Method
func (d *Date) SetYear(year int) error {
if year < 1 {
return errors.New("invalid year")
}
d.year = year
return nil
}
// SetMonth Method
func (d *Date) SetMonth(month int) error {
if month < 1 || month > 12 {
return errors.New("invalid month")
}
d.month = month
return nil
}
// SetDay Method
func (d *Date) SetDay(day int) error {
if day < 1 || day > 31 {
return errors.New("invalid day")
}
d.day = day
return nil
}
// Getter Methods
// Year Method
func (d *Date) Year() int {
return d.year
}
// Month Method
func (d *Date) Month() int {
return d.month
}
// Day Method
func (d *Date) Day() int {
return d.day
}

23
pkg/date/event.go Normal file
View File

@ -0,0 +1,23 @@
package calendar
import (
"errors"
"unicode/utf8"
)
type Event struct {
title string
Date
}
func (e *Event) Title() string {
return e.title
}
func (e *Event) SetTitle(title string) error {
if utf8.RuneCountInString(title) > 32 {
return errors.New("invalid title length")
}
e.title = title
return nil
}