Skip to content

Conversation

@FreshtaM
Copy link
Contributor

@FreshtaM FreshtaM commented Nov 19, 2025

Short Description

Added correct_time_zone for POI and related to this issue. Changed 2 files: DatabaseConnector.ts and PoiModel.ts.
PR labels: native and shared.

Proposed Changes

  • Updated PoiModel.ts to use timezone for isCurrentlyOpen.
  • Updated DatabaseConnector.ts to map timezone from CMS.

Side Effects

None expected. Only POI opening hours behavior is affected.

Testing

  • Check that isCurrentlyOpen now correctly reflects POI status in different timezones.
  • Verify no errors occur when POIs have null or missing timezone.
  • Existing unit tests pass.

Resolved Issues

Fixes: #3619

@steffenkleinle steffenkleinle changed the title 3619: changed DatabaseConnector.ts and PoiModel for correct time_zone 3619: Use correct timezone for pois Nov 20, 2025
@steffenkleinle steffenkleinle changed the title 3619: Use correct timezone for pois 3619: Use correct timezone for poi timeslots Nov 20, 2025
Copy link
Member

@steffenkleinle steffenkleinle left a 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.

Comment on lines 117 to 134
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))
})
}
Copy link
Member

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?

Copy link
Contributor Author

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 .

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))
Copy link
Member

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?

Copy link
Contributor

@LeandraH LeandraH left a 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,
Copy link
Contributor

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 }[]
Copy link
Contributor

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,
Copy link
Contributor

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

Suggested change
timezone: timeslot.timezone ?? undefined,
timezone: timeslot.timezone,

this._organization = organization
this._barrierFree = barrierFree
}

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use correct timezones for poi timeslots

5 participants