package tfelem import ( "git.swzry.com/zry/YAGTF/yagtf/utils" "strconv" "time" ) type HourElement struct { Fill bool Use12hFormat bool } func (this *HourElement) ExpectedSize() int { return 2 } func (this *HourElement) PrintElement(t time.Time) string { h := t.Hour() if h > 12 && this.Use12hFormat { h -= 12 } if this.Fill { return utils.GetFilledNumberWithTruncate(h, 2) } else { return strconv.Itoa(h) } } func NewHour24hElement(fill bool) *HourElement { return &HourElement{ Use12hFormat: false, Fill: fill, } } func NewHour12hElement(fill bool) *HourElement { return &HourElement{ Use12hFormat: true, Fill: fill, } }