From b306787978140aeed48e22ef4ce71b901771fe6b Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Thu, 23 Mar 2017 07:44:45 -0500 Subject: [PATCH] Fixed TimeZone sorting issue Also added some more colors --- config_mode.go | 2 +- main.go | 8 ++++++-- struct_account.go | 1 + struct_event.go | 14 +++++++++----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/config_mode.go b/config_mode.go index 878ed9a..e442b40 100644 --- a/config_mode.go +++ b/config_mode.go @@ -173,7 +173,7 @@ func drawCalList(g *gocui.Gui, v *gocui.View) error { } else { calSumTxt += " " } - calSumTxt += "] " + list[i].Summary + calSumTxt += "] " + list[i].Summary + " " + list[i].BackgroundColor spc := strings.Repeat(" ", width-len(calSumTxt)-2) fmt.Fprintln(v, calSumTxt+spc) } diff --git a/main.go b/main.go index 9a05b93..bd8c5a4 100644 --- a/main.go +++ b/main.go @@ -442,12 +442,16 @@ func CalColToAnsi(col calendar.ColorDefinition) *color.Color { //colWhite := 7 var hexToAnsi = func(hex string) (int, error) { - switch hex { + switch strings.ToLower(hex) { + case "#a47ae2", "#9a9cff", "#4986e7": + return colBlue, nil case "#7bd148": return colGreen, nil + case "#9fc6e7", "#9fe1e7": + return colCyan, nil case "#f83a22", "#ac725e": return colRed, nil - case "#fad165": + case "#fad165", "#ff7537", "#e6c800": return colYellow, nil } return 0, errors.New("Not found") diff --git a/struct_account.go b/struct_account.go index e5f7291..480c010 100644 --- a/struct_account.go +++ b/struct_account.go @@ -81,6 +81,7 @@ func (a *Account) GetTodaysActiveEvents() []Event { } } } + sort.Sort(ByStartTime(ret)) for i := range ret { ret[i].InstanceId = startIdx startIdx++ diff --git a/struct_event.go b/struct_event.go index d1a6756..8a1730a 100644 --- a/struct_event.go +++ b/struct_event.go @@ -87,7 +87,7 @@ func (e *Event) GetStartTimeString() string { func (e *Event) GetStartTime() time.Time { tm, _ := time.Parse(time.RFC3339, e.Start.DateTime) - return tm + return tm.Local() } func (e *Event) GetEndTimeString() string { @@ -100,7 +100,7 @@ func (e *Event) GetEndTimeString() string { func (e *Event) GetEndTime() time.Time { tm, _ := time.Parse(time.RFC3339, e.End.DateTime) - return tm + return tm.Local() } func GoogleEventToLocalWithId(e *calendar.Event, cId string) *Event { @@ -288,6 +288,10 @@ func LocalCreatorToGoogle(a *EventAttendee) *calendar.EventCreator { type ByStartTime []Event -func (a ByStartTime) Len() int { return len(a) } -func (a ByStartTime) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a ByStartTime) Less(i, j int) bool { return a[i].Start.DateTime < a[j].Start.DateTime } +func (a ByStartTime) Len() int { return len(a) } +func (a ByStartTime) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByStartTime) Less(i, j int) bool { + st1, _ := time.Parse(time.RFC3339, a[i].Start.DateTime) + st2, _ := time.Parse(time.RFC3339, a[j].Start.DateTime) + return st2.After(st1) +}