mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Display all day events in calendar, see #306
This commit is contained in:
parent
cb29167ad1
commit
c8ab4af790
@ -69,33 +69,37 @@ func (calEvent *CalEvent) ResponseFor(email string) string {
|
|||||||
|
|
||||||
func (calEvent *CalEvent) End() time.Time {
|
func (calEvent *CalEvent) End() time.Time {
|
||||||
var calcTime string
|
var calcTime string
|
||||||
|
var end time.Time
|
||||||
|
|
||||||
if calEvent.AllDay() {
|
if calEvent.AllDay() {
|
||||||
calcTime = calEvent.event.End.Date
|
calcTime = calEvent.event.End.Date
|
||||||
|
end, _ = time.ParseInLocation("2006-01-02", calcTime, time.Local)
|
||||||
} else {
|
} else {
|
||||||
calcTime = calEvent.event.End.DateTime
|
calcTime = calEvent.event.End.DateTime
|
||||||
|
end, _ = time.Parse(time.RFC3339, calcTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
end, _ := time.Parse(time.RFC3339, calcTime)
|
|
||||||
return end
|
return end
|
||||||
}
|
}
|
||||||
|
|
||||||
func (calEvent *CalEvent) Start() time.Time {
|
func (calEvent *CalEvent) Start() time.Time {
|
||||||
var calcTime string
|
var calcTime string
|
||||||
|
var start time.Time
|
||||||
|
|
||||||
if calEvent.AllDay() {
|
if calEvent.AllDay() {
|
||||||
calcTime = calEvent.event.Start.Date
|
calcTime = calEvent.event.Start.Date
|
||||||
|
start, _ = time.ParseInLocation("2006-01-02", calcTime, time.Local)
|
||||||
} else {
|
} else {
|
||||||
calcTime = calEvent.event.Start.DateTime
|
calcTime = calEvent.event.Start.DateTime
|
||||||
|
start, _ = time.Parse(time.RFC3339, calcTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
start, _ := time.Parse(time.RFC3339, calcTime)
|
|
||||||
return start
|
return start
|
||||||
}
|
}
|
||||||
|
|
||||||
func (calEvent *CalEvent) Timestamp() string {
|
func (calEvent *CalEvent) Timestamp() string {
|
||||||
if calEvent.AllDay() {
|
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)
|
return startTime.Format(wtf.FriendlyDateFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +32,8 @@ func (widget *Widget) display() {
|
|||||||
widget.mutex.Lock()
|
widget.mutex.Lock()
|
||||||
defer widget.mutex.Unlock()
|
defer widget.mutex.Unlock()
|
||||||
|
|
||||||
_, timedEvents := widget.sortedEvents()
|
|
||||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
|
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 {
|
func (widget *Widget) contentFrom(calEvents []*CalEvent) string {
|
||||||
@ -51,6 +50,9 @@ func (widget *Widget) contentFrom(calEvents []*CalEvent) string {
|
|||||||
|
|
||||||
for _, calEvent := range calEvents {
|
for _, calEvent := range calEvents {
|
||||||
timestamp := fmt.Sprintf("[%s]%s", widget.descriptionColor(calEvent), calEvent.Timestamp())
|
timestamp := fmt.Sprintf("[%s]%s", widget.descriptionColor(calEvent), calEvent.Timestamp())
|
||||||
|
if calEvent.AllDay() {
|
||||||
|
timestamp = ""
|
||||||
|
}
|
||||||
|
|
||||||
title := fmt.Sprintf("[%s]%s",
|
title := fmt.Sprintf("[%s]%s",
|
||||||
widget.titleColor(calEvent),
|
widget.titleColor(calEvent),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user