1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Grey out past calendar event descriptions

This commit is contained in:
Chris Cummer 2018-03-29 11:32:43 -07:00 committed by Chris Cummer
parent b0184bca2d
commit 57b0e96d64

View File

@ -22,9 +22,7 @@ func Widget() tview.Primitive {
ts, _ := time.Parse(time.RFC3339, item.Start.DateTime)
timestamp := ts.Format("Mon Jan _2 15:04:05 2006")
color := colorize(item, ts)
str := fmt.Sprintf(" [%s]%s[white]\n %s\n\n", color, item.Summary, timestamp)
str := fmt.Sprintf(" [%s]%s[white]\n [%s]%s[white]\n\n", titleColor(item), item.Summary, descriptionColor(item), timestamp)
data = data + str
}
@ -33,7 +31,9 @@ func Widget() tview.Primitive {
return widget
}
func colorize(item *calendar.Event, ts time.Time) string {
func titleColor(item *calendar.Event) string {
ts, _ := time.Parse(time.RFC3339, item.Start.DateTime)
color := "red"
if strings.Contains(item.Summary, "1on1") {
color = "green"
@ -45,3 +45,15 @@ func colorize(item *calendar.Event, ts time.Time) string {
return color
}
func descriptionColor(item *calendar.Event) string {
ts, _ := time.Parse(time.RFC3339, item.Start.DateTime)
color := "white"
if ts.Before(time.Now()) {
color = "grey"
}
return color
}