Fixed TimeZone sorting issue

Also added some more colors
This commit is contained in:
Brian Buller 2017-03-23 07:44:45 -05:00
parent c4e55cc52f
commit b306787978
4 changed files with 17 additions and 8 deletions

View File

@ -173,7 +173,7 @@ func drawCalList(g *gocui.Gui, v *gocui.View) error {
} else { } else {
calSumTxt += " " calSumTxt += " "
} }
calSumTxt += "] " + list[i].Summary calSumTxt += "] " + list[i].Summary + " " + list[i].BackgroundColor
spc := strings.Repeat(" ", width-len(calSumTxt)-2) spc := strings.Repeat(" ", width-len(calSumTxt)-2)
fmt.Fprintln(v, calSumTxt+spc) fmt.Fprintln(v, calSumTxt+spc)
} }

View File

@ -442,12 +442,16 @@ func CalColToAnsi(col calendar.ColorDefinition) *color.Color {
//colWhite := 7 //colWhite := 7
var hexToAnsi = func(hex string) (int, error) { var hexToAnsi = func(hex string) (int, error) {
switch hex { switch strings.ToLower(hex) {
case "#a47ae2", "#9a9cff", "#4986e7":
return colBlue, nil
case "#7bd148": case "#7bd148":
return colGreen, nil return colGreen, nil
case "#9fc6e7", "#9fe1e7":
return colCyan, nil
case "#f83a22", "#ac725e": case "#f83a22", "#ac725e":
return colRed, nil return colRed, nil
case "#fad165": case "#fad165", "#ff7537", "#e6c800":
return colYellow, nil return colYellow, nil
} }
return 0, errors.New("Not found") return 0, errors.New("Not found")

View File

@ -81,6 +81,7 @@ func (a *Account) GetTodaysActiveEvents() []Event {
} }
} }
} }
sort.Sort(ByStartTime(ret))
for i := range ret { for i := range ret {
ret[i].InstanceId = startIdx ret[i].InstanceId = startIdx
startIdx++ startIdx++

View File

@ -87,7 +87,7 @@ func (e *Event) GetStartTimeString() string {
func (e *Event) GetStartTime() time.Time { func (e *Event) GetStartTime() time.Time {
tm, _ := time.Parse(time.RFC3339, e.Start.DateTime) tm, _ := time.Parse(time.RFC3339, e.Start.DateTime)
return tm return tm.Local()
} }
func (e *Event) GetEndTimeString() string { func (e *Event) GetEndTimeString() string {
@ -100,7 +100,7 @@ func (e *Event) GetEndTimeString() string {
func (e *Event) GetEndTime() time.Time { func (e *Event) GetEndTime() time.Time {
tm, _ := time.Parse(time.RFC3339, e.End.DateTime) tm, _ := time.Parse(time.RFC3339, e.End.DateTime)
return tm return tm.Local()
} }
func GoogleEventToLocalWithId(e *calendar.Event, cId string) *Event { func GoogleEventToLocalWithId(e *calendar.Event, cId string) *Event {
@ -288,6 +288,10 @@ func LocalCreatorToGoogle(a *EventAttendee) *calendar.EventCreator {
type ByStartTime []Event type ByStartTime []Event
func (a ByStartTime) Len() int { return len(a) } 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) 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) 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)
}