Dan Anglin
fa8dbe68e9
Allow users to limit the amount of employment history shown in the PDF document by specifying a time range. This is a breaking change as the structure of the CV needs to slightly change. The employment's start and end dates need to be represented as integers. Additional refactoring: - The CV type is now in the internal cv package. - The template functions are now in the internal templateFuncs package.
36 lines
667 B
Go
36 lines
667 B
Go
package templates
|
|
|
|
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
|
|
}
|