Improve timezone handling in WriteMarkdown function of markdown.go by adding error checking for LoadLocation and providing a fallback to a fixed timezone if loading fails.

This commit is contained in:
Luke Hagar
2025-09-12 19:06:00 +00:00
parent d54ac41670
commit 3a9fdfb479

View File

@@ -57,7 +57,10 @@ func WriteMarkdown(path string, results []web.Result, s Summary) (string, error)
if dur < 0 {
dur = 0
}
loc, _ := time.LoadLocation("America/Chicago")
loc, tzErr := time.LoadLocation("America/Chicago")
if tzErr != nil || loc == nil {
loc = time.FixedZone("CST", -6*60*60)
}
buf.WriteString(fmt.Sprintf("Last Run: %s (Duration: %s)\n\n", s.StartedAt.In(loc).Format("2006-01-02 15:04:05 MST"), dur.Truncate(time.Millisecond)))
// Summary list: Pass, Fail, Total