github.com/wtfutil/wtf@v0.43.0/modules/bamboohr/item.go (about) 1 package bamboohr 2 3 import ( 4 "fmt" 5 6 "github.com/wtfutil/wtf/wtf" 7 ) 8 9 type Item struct { 10 Employee Employee `xml:"employee"` 11 End string `xml:"end"` 12 Holiday string `xml:"holiday"` 13 Start string `xml:"start"` 14 Type string `xml:"type,attr"` 15 } 16 17 func (item *Item) String() string { 18 return fmt.Sprintf("Item: %s, %s, %s, %s", item.Type, item.Employee.Name, item.Start, item.End) 19 } 20 21 /* -------------------- Exported Functions -------------------- */ 22 23 func (item *Item) IsOneDay() bool { 24 return item.Start == item.End 25 } 26 27 func (item *Item) Name() string { 28 if (item.Employee != Employee{}) { 29 return item.Employee.Name 30 } 31 32 return item.Holiday 33 } 34 35 func (item *Item) PrettyStart() string { 36 return wtf.PrettyDate(item.Start) 37 } 38 39 func (item *Item) PrettyEnd() string { 40 return wtf.PrettyDate(item.End) 41 }