1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/hibp/hibp_breach.go
2019-06-22 15:21:22 -07:00

22 lines
490 B
Go

package hibp
import "time"
// Breach represents a breach in the HIBP system
type Breach struct {
Date string `json:"BreachDate"`
Name string `json:"Name"`
}
// BreachDate returns the date of the breach
func (br *Breach) BreachDate() (time.Time, error) {
dt, err := time.Parse("2006-01-02", br.Date)
if err != nil {
// I would much rather return (nil, err) err but that doesn't seem possible
// Not sure what a better value would be
return time.Now(), err
}
return dt, nil
}