Skip to content

Commit d6c54e2

Browse files
authored
[ID-97] Incorrect event end times (#98)
* Use pointers * Update CHANGELOG.md * Skip end date when unavailable * Fix timer * Do not log --------- Co-authored-by: Petyo Stoyanov <[email protected]>
1 parent ec6ea85 commit d6c54e2

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
- Incorrect event end times [#97](https://github.com/rokwire/gateway-building-block/issues/97)
10+
811
[2.10.0] - 2024-05-16
912
### Changed
1013
- Handle location processing on WebTools import [#90](https://github.com/rokwire/gateway-building-block/issues/90)

core/logic_events.go

+24-12
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ func (e eventsLogic) constructLegacyEvent(g model.WebToolsEvent, id string, now
584584
timeType := g.TimeType
585585

586586
var startDate, startTime, endDate, endTime string
587-
var startDateObj, endDateObj time.Time
587+
var startDateObj, endDateObj *time.Time
588588

589589
chicagoLocation, err := time.LoadLocation("America/Chicago")
590590
if err != nil {
@@ -595,35 +595,47 @@ func (e eventsLogic) constructLegacyEvent(g model.WebToolsEvent, id string, now
595595
startDate = g.StartDate
596596
startTime = g.StartTime
597597
startDateTimeStr := fmt.Sprintf("%s %s", startDate, startTime)
598-
startDateObj, _ = time.ParseInLocation("1/2/2006 3:04 pm", startDateTimeStr, chicagoLocation)
598+
startDateObjTmp, _ := time.ParseInLocation("1/2/2006 3:04 pm", startDateTimeStr, chicagoLocation)
599+
startDateObj = &startDateObjTmp
599600

600-
endDate = g.EndDate
601+
/*endDate = g.EndDate
601602
endDateTimeStr := fmt.Sprintf("%s 11:59 pm", endDate)
602-
endDateObj, _ = time.ParseInLocation("1/2/2006 3:04 pm", endDateTimeStr, chicagoLocation)
603+
endDateObjTmp, _ := time.ParseInLocation("1/2/2006 3:04 pm", endDateTimeStr, chicagoLocation)
604+
endDateObj = &endDateObjTmp*/
603605
} else if timeType == "START_AND_END_TIME" {
604606
startDate = g.StartDate
605607
startTime = g.StartTime
606608
startDateTimeStr := fmt.Sprintf("%s %s", startDate, startTime)
607-
startDateObj, _ = time.ParseInLocation("1/2/2006 3:04 pm", startDateTimeStr, chicagoLocation)
609+
startDateObjTmp, _ := time.ParseInLocation("1/2/2006 3:04 pm", startDateTimeStr, chicagoLocation)
610+
startDateObj = &startDateObjTmp
608611

609612
endDate = g.EndDate
610613
endTime = g.EndTime
611614
endDateTimeStr := fmt.Sprintf("%s %s", endDate, endTime)
612-
endDateObj, _ = time.ParseInLocation("1/2/2006 3:04 pm", endDateTimeStr, chicagoLocation)
615+
endDateObjTmp, _ := time.ParseInLocation("1/2/2006 3:04 pm", endDateTimeStr, chicagoLocation)
616+
endDateObj = &endDateObjTmp
613617
} else if timeType == "NONE" {
614618
allDay = true
615619

616620
startDate = g.StartDate
617-
endDate = g.EndDate
618621
startDateTimeStr := fmt.Sprintf("%s 12:00 am", startDate)
619-
startDateObj, _ = time.ParseInLocation("1/2/2006 3:04 pm", startDateTimeStr, chicagoLocation)
622+
startDateObjTmp, _ := time.ParseInLocation("1/2/2006 3:04 pm", startDateTimeStr, chicagoLocation)
623+
startDateObj = &startDateObjTmp
620624

621-
endDateTimeStr := fmt.Sprintf("%s 11:59 pm", endDate)
622-
endDateObj, _ = time.ParseInLocation("1/2/2006 3:04 pm", endDateTimeStr, chicagoLocation)
625+
/* endDateTimeStr := fmt.Sprintf("%s 11:59 pm", endDate)
626+
endDateObjTmp, _ := time.ParseInLocation("1/2/2006 3:04 pm", endDateTimeStr, chicagoLocation)
627+
endDateObj = &endDateObjTmp */
623628
}
624629

625-
startDateStr := startDateObj.UTC().Format("Mon, 02 Jan 2006 15:04:05 GMT")
626-
endDateStr := endDateObj.UTC().Format("Mon, 02 Jan 2006 15:04:05 GMT")
630+
startDateStr := ""
631+
endDateStr := ""
632+
633+
if startDateObj != nil {
634+
startDateStr = startDateObj.UTC().Format("Mon, 02 Jan 2006 15:04:05 GMT")
635+
}
636+
if endDateObj != nil {
637+
endDateStr = endDateObj.UTC().Format("Mon, 02 Jan 2006 15:04:05 GMT")
638+
}
627639

628640
//end - start date + end date (+all day)
629641

0 commit comments

Comments
 (0)