2015-01-29 11:35:15 +01:00
|
|
|
// generated by jsonenums -type=WeekDay; DO NOT EDIT
|
|
|
|
|
2015-01-29 17:00:50 +01:00
|
|
|
package main
|
2015-01-29 11:35:15 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (r WeekDay) String() string {
|
|
|
|
switch r {
|
|
|
|
|
|
|
|
case Monday:
|
|
|
|
return "Monday"
|
|
|
|
|
|
|
|
case Tuesday:
|
|
|
|
return "Tuesday"
|
|
|
|
|
|
|
|
case Wednesday:
|
|
|
|
return "Wednesday"
|
|
|
|
|
|
|
|
case Thursday:
|
|
|
|
return "Thursday"
|
|
|
|
|
|
|
|
case Friday:
|
|
|
|
return "Friday"
|
|
|
|
|
|
|
|
case Saturday:
|
|
|
|
return "Saturday"
|
|
|
|
|
|
|
|
case Sunday:
|
|
|
|
return "Sunday"
|
|
|
|
|
|
|
|
default:
|
|
|
|
return "unknown WeekDay"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r WeekDay) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(r.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *WeekDay) UnmarshalJSON(data []byte) error {
|
|
|
|
var s string
|
|
|
|
if err := json.Unmarshal(data, &s); err != nil {
|
|
|
|
return fmt.Errorf("WeekDay should be a string, got %s", data)
|
|
|
|
}
|
|
|
|
switch s {
|
|
|
|
|
|
|
|
case "Monday":
|
|
|
|
*r = Monday
|
|
|
|
|
|
|
|
case "Tuesday":
|
|
|
|
*r = Tuesday
|
|
|
|
|
|
|
|
case "Wednesday":
|
|
|
|
*r = Wednesday
|
|
|
|
|
|
|
|
case "Thursday":
|
|
|
|
*r = Thursday
|
|
|
|
|
|
|
|
case "Friday":
|
|
|
|
*r = Friday
|
|
|
|
|
|
|
|
case "Saturday":
|
|
|
|
*r = Saturday
|
|
|
|
|
|
|
|
case "Sunday":
|
|
|
|
*r = Sunday
|
|
|
|
|
|
|
|
default:
|
2015-01-29 17:00:50 +01:00
|
|
|
return fmt.Errorf("invalid WeekDay %q", s)
|
2015-01-29 11:35:15 +01:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|