From 10142ebddcb3940e8eaf345cd5c6a0955c71e5b1 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Mon, 9 Apr 2018 13:30:21 -0700 Subject: [PATCH] Add the ability to get BambooHR away tomorrow --- bamboohr/widget.go | 10 +++++++--- wtf/utils.go | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bamboohr/widget.go b/bamboohr/widget.go index 0de30f73..7b370caa 100644 --- a/bamboohr/widget.go +++ b/bamboohr/widget.go @@ -36,13 +36,17 @@ func (widget *Widget) Refresh() { url, _ := Config.String("wtf.bamboohr.url") client := NewClient(url) - items := client.Away("timeOff", wtf.Today(), wtf.Today()) + todayItems := client.Away( + "timeOff", + wtf.Today().Format(wtf.DateFormat), + wtf.Today().Format(wtf.DateFormat), + ) - widget.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(items))) + widget.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(todayItems))) widget.RefreshedAt = time.Now() widget.View.Clear() - fmt.Fprintf(widget.View, "%s", widget.contentFrom(items)) + fmt.Fprintf(widget.View, "%s", widget.contentFrom(todayItems)) } /* -------------------- Unexported Functions -------------------- */ diff --git a/wtf/utils.go b/wtf/utils.go index a46dffa7..1256ef69 100644 --- a/wtf/utils.go +++ b/wtf/utils.go @@ -72,9 +72,12 @@ func PrettyDate(dateStr string) string { return fmt.Sprint(newTime.Format("Jan 2, 2006")) } -func Today() string { - localNow := time.Now().Local() - return localNow.Format("2006-01-02") +func Today() time.Time { + return time.Now().Local() +} + +func Tomorrow() time.Time { + return Today().AddDate(0, 0, 1) } func ToInts(slice []interface{}) []int {