spruce/internal/cv/types.go
Dan Anglin c53978cd91
feat: add a field for location type, code refactor
- feat: add a field for the type of work location (e.g. hybrid)
- refactor: move the Tex and PDF generating code to a new internal
  package which also moves the templates there as well.
- fix: add a default value for the --output field for the generate
  command.
- fix: add an error for when the user does not specify an input file
  when generating the PDF.
- fix: the package name for each of the files in the templateFuncs
  package.
2023-08-15 17:25:00 +01:00

68 lines
1.6 KiB
Go

package cv
import (
"fmt"
"time"
)
type CV struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
JobTitle string `json:"jobTitle"`
Contact map[string]string `json:"contact"`
Links map[string]string `json:"links"`
Summary []string `json:"summary"`
Skills []Skills `json:"skills"`
Employment []Experience `json:"employment"`
Education []Experience `json:"education"`
Interests []string `json:"interests"`
}
type Skills struct {
Category string `json:"category"`
Values []string `json:"values"`
}
type Experience struct {
Company string `json:"company"`
School string `json:"school"`
Location string `json:"location"`
LocationType string `json:"locationType"`
JobTitle string `json:"jobTitle"`
Qualification string `json:"qualification"`
Duration Duration `json:"duration"`
Details []string `json:"details"`
}
type Duration struct {
Start Date `json:"start"`
End Date `json:"end"`
Present bool `json:"present"`
}
func (d Duration) After(t time.Time) (bool, error) {
endDate, err := d.End.ParseDate()
if err != nil {
return false, err
}
return endDate.After(t), nil
}
type Date struct {
Year int `json:"year"`
Month int `json:"month"`
Day int `json:"day"`
}
func (d Date) ParseDate() (time.Time, error) {
dateStr := fmt.Sprintf("%d-%02d-%02d", d.Year, d.Month, d.Day)
date, err := time.Parse(time.DateOnly, dateStr)
if err != nil {
return time.Time{}, fmt.Errorf("unable to parse the date; %w", err)
}
return date, nil
}