github.com/wtfutil/wtf@v0.43.0/modules/hibp/hibp_breach.go (about)

     1  package hibp
     2  
     3  import "time"
     4  
     5  // Breach represents a breach in the HIBP system
     6  type Breach struct {
     7  	Date string `json:"BreachDate"`
     8  	Name string `json:"Name"`
     9  }
    10  
    11  // BreachDate returns the date of the breach
    12  func (br *Breach) BreachDate() (time.Time, error) {
    13  	dt, err := time.Parse("2006-01-02", br.Date)
    14  	if err != nil {
    15  		// I would much rather return (nil, err) err but that doesn't seem possible
    16  		// Not sure what a better value would be
    17  		return time.Now(), err
    18  	}
    19  
    20  	return dt, nil
    21  }