Fixed bugs and added hourly forecast

This commit is contained in:
2025-07-31 16:06:57 +02:00
parent 82f67515e7
commit f44c671052
12 changed files with 383 additions and 129 deletions

View File

@@ -33,3 +33,32 @@ func (date ZephyrDate) MarshalJSON() ([]byte, error) {
return []byte("\"" + fmtDate + "\""), nil
}
type ZephyrTime struct {
Time time.Time
}
func (t *ZephyrTime) UnmarshalJSON(b []byte) error {
s := strings.Trim(string(b), "\"")
if s == "" {
return nil
}
var err error
t.Time, err = time.Parse("15:04", s)
if err != nil {
return err
}
return nil
}
func (t ZephyrTime) MarshalJSON() ([]byte, error) {
if t.Time.IsZero() {
return []byte("\"\""), nil
}
fmtTime := t.Time.Format("3:04 PM")
return []byte("\"" + fmtTime + "\""), nil
}