fixed tio arvelie
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
type Arvelie string
|
||||
|
||||
func (a *Arvelie) isValid() bool {
|
||||
func (a *Arvelie) IsValid() bool {
|
||||
if a != nil {
|
||||
return strings.EqualFold(string(*a), string(FromDate(ToDate(*a))))
|
||||
}
|
||||
@@ -29,7 +29,7 @@ func ToDate(a Arvelie) time.Time {
|
||||
mon = (int(m[0]) - 65)
|
||||
}
|
||||
|
||||
doty := (math.Floor(float64(mon)*14) + math.Floor(float64(d)) - 1)
|
||||
doty := (math.Floor(float64(mon)*14) + float64(d) - 1)
|
||||
yr, _ := strconv.Atoi(fmt.Sprintf("20%s", y))
|
||||
return time.Date(yr, 1, 1, 0, 0, 0, 0, time.UTC).AddDate(0, 0, int(doty))
|
||||
}
|
||||
@@ -42,17 +42,15 @@ func FromDate(date time.Time) Arvelie {
|
||||
if doty == 365 || doty == 366 {
|
||||
m = "+"
|
||||
} else {
|
||||
m = strings.ToUpper(string([]byte{byte(97 + math.Floor(float64(doty/14)))}))
|
||||
m = strings.ToUpper(string([]byte{byte(97 + math.Floor(float64(doty)/14))}))
|
||||
}
|
||||
|
||||
var d string
|
||||
switch doty {
|
||||
case 365:
|
||||
d = fmt.Sprintf("%02d", 1)
|
||||
break
|
||||
case 366:
|
||||
d = fmt.Sprintf("%02d", 2)
|
||||
break
|
||||
default:
|
||||
d = fmt.Sprintf("%02d", (doty % 14))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user