Shai Cohen- Date for two: Server, Client, and Datetime in a Multi-timezone environment
HTML-код
- Опубликовано: 29 окт 2024
- Any complex Django-based app will include many models that use the DateTime field, and the clients use those fields.
Assuming all our clients will always be in the same timezone is wrong for a globally used app.
Pythons DateTime and pytz packages can help you localize the information, but what is the “right localization”? And more importantly, how can we assume where to localize from?
When designing a flow that handles DateTime fields in server-client data exchange, timezone conversions are the main issue.
Another challenge is what can we assume about the DateTime data that comes from the client when they send a PUT request with a DateTime field? What should the response assume? What if the client sends a GET request without any additional data?
In this talk, we will address those issues by demonstrating a simple “Timed Assignment App” that can be used globally.
I’ll show the thought process that might go through your mind when designing the time features for this app, try different solutions using python packages, and finally suggest the “aviation method” for solving all the problems before they even happen.