Skip to content

Commit

Permalink
Display all day events in calendar, see wtfutil#306
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Eden committed Oct 4, 2018
1 parent cb29167 commit 8ca0ece
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions gcal/cal_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,37 @@ func (calEvent *CalEvent) ResponseFor(email string) string {

func (calEvent *CalEvent) End() time.Time {
var calcTime string
var end time.Time

if calEvent.AllDay() {
calcTime = calEvent.event.End.Date
end, _ = time.ParseInLocation("2006-01-02", calcTime, time.Local)
} else {
calcTime = calEvent.event.End.DateTime
end, _ = time.Parse(time.RFC3339, calcTime)
}

end, _ := time.Parse(time.RFC3339, calcTime)
return end
}

func (calEvent *CalEvent) Start() time.Time {
var calcTime string
var start time.Time

if calEvent.AllDay() {
calcTime = calEvent.event.Start.Date
start, _ = time.ParseInLocation("2006-01-02", calcTime, time.Local)
} else {
calcTime = calEvent.event.Start.DateTime
start, _ = time.Parse(time.RFC3339, calcTime)
}

start, _ := time.Parse(time.RFC3339, calcTime)
return start
}

func (calEvent *CalEvent) Timestamp() string {
if calEvent.AllDay() {
startTime, _ := time.Parse("2006-01-02", calEvent.event.Start.Date)
startTime, _ := time.ParseInLocation("2006-01-02", calEvent.event.Start.Date, time.Local)
return startTime.Format(wtf.FriendlyDateFormat)
}

Expand Down
3 changes: 1 addition & 2 deletions gcal/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ func (widget *Widget) display() {
widget.mutex.Lock()
defer widget.mutex.Unlock()

_, timedEvents := widget.sortedEvents()
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
widget.View.SetText(widget.contentFrom(timedEvents))
widget.View.SetText(widget.contentFrom(widget.calEvents))
}

func (widget *Widget) contentFrom(calEvents []*CalEvent) string {
Expand Down

0 comments on commit 8ca0ece

Please sign in to comment.