-
Notifications
You must be signed in to change notification settings - Fork 28
3619: Use correct timezone for poi timeslots #3731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this looks really good already and works as expected (tested on firefox). However, please make sure not to do unrelated changes if there is no specific reason for it. Also, there are currently still some issues with prettier, linting and ts checks. Please try to resolve them :)
Another note: It is usually a good idea to stick to the PR template and not copy most of the issue description here.
shared/api/models/PoiModel.ts
Outdated
| get isCurrentlyOpen(): boolean { | ||
| if (!this.openingHours) return false | ||
|
|
||
| const now = DateTime.now() | ||
| const weekdayIndex = now.weekday - 1 | ||
| const today = this.openingHours[weekdayIndex] | ||
|
|
||
| if (!today) return false | ||
| if (today.allDay) return true | ||
|
|
||
| return today.timeSlots.some(timeslot => { | ||
| const zone = timeslot.timezone ?? 'UTC' | ||
| const start = DateTime.fromFormat(timeslot.start, 'HH:mm', { zone }) | ||
| const end = DateTime.fromFormat(timeslot.end, 'HH:mm', { zone }) | ||
|
|
||
| return Interval.fromDateTimes(start, end).contains(now.setZone(zone)) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Please revert unrelated changes, except they were done on purpose. Why did you choose to rename some of the variables here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello thank you for your review
the unrelated code has been reverted .
shared/api/models/PoiModel.ts
Outdated
| const start = DateTime.fromFormat(timeslot.start, 'HH:mm', { zone }) | ||
| const end = DateTime.fromFormat(timeslot.end, 'HH:mm', { zone }) | ||
|
|
||
| return Interval.fromDateTimes(start, end).contains(now.setZone(zone)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Is it really necessary to convert now to the same time zone?
LeandraH
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
| timeSlots: hours.timeSlots.map(timeslot => ({ | ||
| start: timeslot.start, | ||
| end: timeslot.end, | ||
| timezone: (timeslot as { timezone: string }).timezone ? (timeslot as { timezone: string }).timezone : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks redundant.
| openAllDay: boolean | ||
| closedAllDay: boolean | ||
| timeSlots: { start: string; end: string }[] | ||
| timeSlots: { start: string; end: string }[] | { start: string; end: string; timezone: string }[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be optional instead of or operator?
timeSlots: { start: string; end: string; timezone?: string }[]| timeSlots: hours.timeSlots.map(timeslot => ({ | ||
| start: timeslot.start, | ||
| end: timeslot.end, | ||
| timezone: timeslot.timezone ?? undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add the nullish thing if it's already string | undefined
| timezone: timeslot.timezone ?? undefined, | |
| timezone: timeslot.timezone, |
| this._organization = organization | ||
| this._barrierFree = barrierFree | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Please revert these unnecessary blank line deletion/assertion.
Short Description
Added correct_time_zone for POI and related to this issue. Changed 2 files:
DatabaseConnector.tsandPoiModel.ts.PR labels:
nativeandshared.Proposed Changes
PoiModel.tsto use timezone forisCurrentlyOpen.DatabaseConnector.tsto map timezone from CMS.Side Effects
None expected. Only POI opening hours behavior is affected.
Testing
isCurrentlyOpennow correctly reflects POI status in different timezones.nullor missing timezone.Resolved Issues
Fixes: #3619