evcc-io/tariff/fixed/month_enumer.go

118 lines
3 KiB
Go

// Code generated by "enumer -type Month"; DO NOT EDIT.
package fixed
import (
"fmt"
"strings"
)
const _MonthName = "JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember"
var _MonthIndex = [...]uint8{0, 7, 15, 20, 25, 28, 32, 36, 42, 51, 58, 66, 74}
const _MonthLowerName = "januaryfebruarymarchaprilmayjunejulyaugustseptemberoctobernovemberdecember"
func (i Month) String() string {
if i < 0 || i >= Month(len(_MonthIndex)-1) {
return fmt.Sprintf("Month(%d)", i)
}
return _MonthName[_MonthIndex[i]:_MonthIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _MonthNoOp() {
var x [1]struct{}
_ = x[January-(0)]
_ = x[February-(1)]
_ = x[March-(2)]
_ = x[April-(3)]
_ = x[May-(4)]
_ = x[June-(5)]
_ = x[July-(6)]
_ = x[August-(7)]
_ = x[September-(8)]
_ = x[October-(9)]
_ = x[November-(10)]
_ = x[December-(11)]
}
var _MonthValues = []Month{January, February, March, April, May, June, July, August, September, October, November, December}
var _MonthNameToValueMap = map[string]Month{
_MonthName[0:7]: January,
_MonthLowerName[0:7]: January,
_MonthName[7:15]: February,
_MonthLowerName[7:15]: February,
_MonthName[15:20]: March,
_MonthLowerName[15:20]: March,
_MonthName[20:25]: April,
_MonthLowerName[20:25]: April,
_MonthName[25:28]: May,
_MonthLowerName[25:28]: May,
_MonthName[28:32]: June,
_MonthLowerName[28:32]: June,
_MonthName[32:36]: July,
_MonthLowerName[32:36]: July,
_MonthName[36:42]: August,
_MonthLowerName[36:42]: August,
_MonthName[42:51]: September,
_MonthLowerName[42:51]: September,
_MonthName[51:58]: October,
_MonthLowerName[51:58]: October,
_MonthName[58:66]: November,
_MonthLowerName[58:66]: November,
_MonthName[66:74]: December,
_MonthLowerName[66:74]: December,
}
var _MonthNames = []string{
_MonthName[0:7],
_MonthName[7:15],
_MonthName[15:20],
_MonthName[20:25],
_MonthName[25:28],
_MonthName[28:32],
_MonthName[32:36],
_MonthName[36:42],
_MonthName[42:51],
_MonthName[51:58],
_MonthName[58:66],
_MonthName[66:74],
}
// MonthString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func MonthString(s string) (Month, error) {
if val, ok := _MonthNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _MonthNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Month values", s)
}
// MonthValues returns all values of the enum
func MonthValues() []Month {
return _MonthValues
}
// MonthStrings returns a slice of all String values of the enum
func MonthStrings() []string {
strs := make([]string, len(_MonthNames))
copy(strs, _MonthNames)
return strs
}
// IsAMonth returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Month) IsAMonth() bool {
for _, v := range _MonthValues {
if i == v {
return true
}
}
return false
}