week.go 459 B

123456789101112131415161718192021222324252627282930
  1. package tfelem
  2. import (
  3. "git.swzry.com/zry/YAGTF/yagtf/utils"
  4. "strconv"
  5. "time"
  6. )
  7. type WeekElement struct {
  8. Fill bool
  9. }
  10. func (this *WeekElement) ExpectedSize() int {
  11. return 2
  12. }
  13. func (this *WeekElement) PrintElement(t time.Time) string {
  14. _, w := t.ISOWeek()
  15. if this.Fill {
  16. return utils.GetFilledNumberWithTruncate(w, 2)
  17. } else {
  18. return strconv.Itoa(w)
  19. }
  20. }
  21. func NewWeekElement(fill bool) *WeekElement {
  22. return &WeekElement{
  23. Fill: fill,
  24. }
  25. }