diff options
| author | Joe Beda <joe.github@bedafamily.com> | 2017-11-06 11:57:04 -0800 |
|---|---|---|
| committer | Joe Beda <joe.github@bedafamily.com> | 2017-11-06 13:35:52 -0800 |
| commit | 1cc0e9748240fc2659ad2d80c610f54880121e16 (patch) | |
| tree | 284def1109488b147dbbc6e27c5f6ea191176f20 /generator/app.go | |
| parent | 56ddf9c24ae7e308e3cbd4cb9c3638d758c53709 (diff) | |
Make time zone explicit
Diffstat (limited to 'generator/app.go')
| -rw-r--r-- | generator/app.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/generator/app.go b/generator/app.go index 2aaced3f..3c6c144d 100644 --- a/generator/app.go +++ b/generator/app.go @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "log" + "net/url" "os" "path/filepath" "sort" @@ -60,8 +61,8 @@ type Lead struct { // Meeting represents a regular meeting for a group. type Meeting struct { Day string - UTC string - PST string + Time string + TZ string `yaml:"tz"` Frequency string } @@ -153,9 +154,22 @@ func getExistingContent(path string) (string, error) { return strings.Join(captured, "\n"), nil } +var funcMap template.FuncMap = template.FuncMap{ + "tzUrlEncode": tzUrlEncode, +} + +// tzUrlEncode returns an url encoded string without the + shortcut. This is +// required as the timezone conversion site we are using doesn't recognize + as +// a valid url escape character. +func tzUrlEncode(tz string) string { + return strings.Replace(url.QueryEscape(tz), "+", "%20", -1) +} + func writeTemplate(templatePath, outputPath string, data interface{}) error { // set up template - t, err := template.ParseFiles(templatePath, filepath.Join(baseGeneratorDir, templateDir, headerTemplate)) + t, err := template.New(filepath.Base(templatePath)). + Funcs(funcMap). + ParseFiles(templatePath, filepath.Join(baseGeneratorDir, templateDir, headerTemplate)) if err != nil { return err } |
