Dan Anglin
c53978cd91
- 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.
36 lines
671 B
Go
36 lines
671 B
Go
package templateFuncs
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"codeflow.dananglin.me.uk/apollo/spruce/internal/cv"
|
|
)
|
|
|
|
// FormatDuration outputs the employment/education
|
|
// duration as a formatted string.
|
|
func FormatDuration(d cv.Duration) string {
|
|
var start string
|
|
|
|
startDate, err := d.Start.ParseDate()
|
|
|
|
if err != nil {
|
|
start = "Unknown"
|
|
} else {
|
|
start = fmt.Sprintf("%s, %d", startDate.Month().String(), startDate.Year())
|
|
}
|
|
|
|
var end string
|
|
|
|
if d.Present {
|
|
end = "Present"
|
|
} else {
|
|
endDate, err := d.End.ParseDate()
|
|
if err != nil {
|
|
end = "Unknown"
|
|
} else {
|
|
end = fmt.Sprintf("%s, %d", endDate.Month().String(), endDate.Year())
|
|
}
|
|
}
|
|
|
|
return start + " - " + end
|
|
}
|