Rails application - how to enter events in the local time zone

I am working on a Rails application that displays a sports graph (in the base table). Each game / event is a row in the db table. The client wants all events to be displayed in chronological order, but also to display the time in the local time zone of the event.

How to add time zone selector to New action? Thus, when the client enters events, they can select the time zone of the event and enter the time of the event in this time zone.

Here's what the chart looks like:

Event 1 19:00 EST Event 2 17:00 PST Event 3 7:00 pm PST

I personally find this confusing, but that is what they want. Thanks in advance.

+3
source share
2 answers

Geoff Buesing wrote a great primer about Rails time zone support back when 2.1 was released.

+2
source

Well, I'm not sure I understood your question directly, but here's my line of thinking - this is the library that I passed by the name tzinfo, which should give Rails the ability to work with time zones, so I assume that you will perform the following assembly list for the window of choice (wikipedia has a complete full list), when the user selects the time zone, sends it to the server, which will calculate the corresponding timings now and send back (maybe, depending on your architecture, you could send only the added hours s to be added or subtracted)

0

Source: https://habr.com/ru/post/1718348/


All Articles