Hi,
I have a digital signage system built with Wappler using NodeJS. The system is used by several hotels located in different time zones in Mexico.
For example:
- Cancun →
America/Cancun - Mexico City →
America/Mexico_City - Tijuana →
America/Tijuana
Each hotel has multiple screens, and each screen displays information specific to that hotel, including a list of restaurants that are currently open.
The problem is that "open now" needs to be calculated using the hotel's local time, not the server time and not the local time of the device/browser displaying the signage.
For example, if I open a Cancun hotel's signage URL from Tijuana, it should still show the restaurants that are currently open according to Cancun time.
I have read the documentation about Server Time Zone, Database Time Zone Handling, and toLocalTime():
However, as I understand it, Server Time Zone is configured globally for the NodeJS target. In my case, a single Wappler application/server needs to handle multiple time zones simultaneously.
Ideally, I would like to store the IANA timezone in the hotel database table:
hotel_id | hotel_name | timezone
1 | Cancun Hotel | America/Cancun
2 | CDMX Hotel | America/Mexico_City
3 | Tijuana Hotel | America/Tijuana
Then, in a Server Connect action, I would like to do something conceptually like:
Get Hotel
↓
hotel.timezone
↓
Get current date/time in that timezone
↓
Filter restaurants that are open at that local time
I specifically want to use IANA time zones instead of fixed UTC offsets because locations such as Tijuana observe daylight saving time.
Is there a native/recommended way in Wappler Server Connect to get the current date/time for a dynamically specified IANA timezone, for example:
America/Tijuana
where the timezone value comes from a database query?
Or would the recommended approach be to create a custom NodeJS formatter/module using Intl.DateTimeFormat?
I would prefer to keep the logic server-side so the result does not depend on the timezone of the browser/device displaying the signage.
Thanks!