How to implement timezone selector? (Quasar best practice)
-
Hi! I’m making an app that will generate some reports. User can have some projects each of that can belongs to different timezones and reports should consider this. I do understand how to get time in selected location from string (ex. “Europe/Moscow”) at the backend, but how to get selectable list of zones in Quasar?
I guess that can be done with momentjs, but there is a warning about this. Thanks for help in advance! -
@nobilik I would tend to use the same timezones as with my backend db.
For example: in Postgres it could be done like below. BUT - please see, that there are 200 of those, and this specific query is quite time consuming, so I would consider using cache for that tz data on client side:
-
@qyloxe Thanks for suggestion! But 5 sec for 200 rows???
For querySELECT DISTINCT(name) FROM pg_timezone_names WHERE name NOT LIKE '%posix%';
I have 113 ms for 608 rows…
However, there are some names like “Factory”, “GMT/+8”, etc. that make things looks ugly… I’ll take a look how to avoid them. -
@nobilik said in How to implement timezone selector? (Quasar best practice):
@qyloxe Thanks for suggestion! But 5 sec for 200 rows???
Yep - I like to test queries with so called “cold cache”. This gives me a “worst case” scenario. Of course, the next queries will return in ms, but in production, with high load, there is a possibility, that the cache will be cleared/overflowed and this specific query could take 5 secs again. Because I know that beforehand I could take some actions and not be surprised. This is a nice article:
https://madusudanan.com/blog/understanding-postgres-caching-in-depth/