Commit 1d524a0c authored by Steve Perkins's avatar Steve Perkins
Browse files

Adds schema version field, and year-only date formatting fuction for templates

parent 2c011abe
......@@ -121,6 +121,15 @@ func ExportResume(resumeData data.ResumeData, templateContent string) (*bytes.Bu
"toUpper": func(s string) string {
return strings.ToUpper(s)
},
"YYYY": func(s string) string {
const inputFormat = "2006-01-02"
dateValue, err := time.Parse(inputFormat, s)
if err != nil {
return s
}
const outputFormat = "2006"
return dateValue.Format(outputFormat)
},
"MYY": func(s string) string {
const inputFormat = "2006-01-02"
dateValue, err := time.Parse(inputFormat, s)
......
......@@ -6,12 +6,18 @@ import (
"io/ioutil"
)
const SCHEMA_VERSION = 1
// ResumeData is the outermost container for resume data.
type ResumeData struct {
// XMLName provides a name for the top-level element, when working with resume data files in XML format. This
// field is ignored when working with files in JSON format.
XMLName xml.Name `xml:"resume" json:"-"`
// TODO: Add a top-level field for schema version
Basics Basics `xml:"basics" json:"basics"`
Work []Work `xml:"work" json:"work"`
// Version is an identifier for the schema structure. If breaking changes occur in the future, then ResumeFodder
// can use this value to recognize the incompatibility and provide options.
Version int `xml:"version" json:"version"`
Basics Basics `xml:"basics" json:"basics"`
Work []Work `xml:"work" json:"work"`
// AdditionalWork is an extra field, not found within the standard JSON-Resume spec. It is intended to store
// employment history that should be presented differently from that in the main "Work" field.
//
......@@ -150,6 +156,7 @@ type Skill struct {
//
func NewResumeData() ResumeData {
return ResumeData{
Version: SCHEMA_VERSION,
Basics: Basics{
Location: Location{},
Profiles: []SocialProfile{{}},
......
......@@ -9,6 +9,7 @@ import (
// A helper function to generate fake `ResumeData` structs, for use by the various test functions.
func GenerateTestResumeData() data.ResumeData {
data := data.ResumeData{
Version: data.SCHEMA_VERSION,
Basics: data.Basics{
Name: "Peter Gibbons",
Email: "peter.gibbons@initech.com",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment