Timezone-affected rails 3 app - ruby-on-rails-3

UPDATE:
Copied from comment made below:
I thought about using a web service against IP address for each visitor to the site but then I wondered about users looking at meetings in locations that span timezones so the timezone has to be associated with the location of the meeting being viewed, not where the user themselves are at that moment in time. I need a user to be able to see a list of meetings (with times and locations) and the times shown are the actual meeting times but the WHERE clause of the SELECT to list the meetings needs to take into account the timezone of each meeting location.
I've looked around and there are plenty of questions asked about using timezones with a rails app.
The issue lies in the fact that the app needs to know which timezone a user is in for it to properly be able to run queries against the database to check for datetimes in the future, for instance.
I don't want regular visitors to my site to need to login for it to work correctly for them so I'm thinking along the following lines:
Admin users login to post an item for a particular location and datetime
When saving the item it uses the [lat,lng] of the location to call the Timezone gem to capture the timezone for the location
I think I need this timezone to be added to an extra field on the same model as the [lat,lng] and the datetime (which rails saves as UTC) ( https://stackoverflow.com/a/2533323 )
I need my model to combine the UTC datetime with its respective timezone so that when a regular user comes to the site the webpage selects items where the UTC+timezone datetimes are in the future
Does that sound possible/correct?
If it sounds confusing just say in a comment and I'll try to reword it a bit better if I can.
Can someone offer any code for the model to create a virtual attribute (I think) that combines UTC datetime with a timezone field?
Thanks

Won't it be better to have the list of countries and their timezones? When user comes to site determine from what country he is and than trying to use native rails timezone methods.
For example I have User and Table models that have created_at params:
Time.zone => (GMT+00:00) UTC
User.last.created_at => Mon, 25 Jun 2012 21:17:25 UTC +00:00
Table.last.created_at => Mon, 16 Jul 2012 14:08:17 UTC +00:00
Time.zone = 'Moscow' => "Moscow"
Time.zone => (GMT+04:00) Moscow
User.last.created_at => Tue, 26 Jun 2012 01:17:25 MSK +04:00
Table.last.created_at => Mon, 16 Jul 2012 18:08:17 MSK +04:00
How to determine the country you should look for gems or some services. I think it will be the service that determine the user country by his IP address.

Related

React Table shows entries based on User Time zone not UTC

I have a table (react/Nodejs) which reads the entries from db and list it in the table. All entries in db are UTC, however depending on the user time zone the table is showing different data. For example in the attached snapshot our week on header is from Sep 19 to Sep 25 but the table shows Sep 26 entry which is outside of the range. That only happens with users on (UTC-xxx) time and not for user on (UTC+xxx). Your help is appreciated? Table Image
Use a timezone library to render it with a specific timezone
The problem is caused when formatting the object to be rendered in the UI, so probably the method you are using is as you say taking into account the users timezone and not a specific one that you set.
To achieve this, you can use a library like moment timezone. Or a variant compatible with your libraries.
Hope it helps.

Issue with Rally custom list with deep export (bug)

I am using Rally "Custom list With Deep export"
We have a field Planned end date. How ever while exporting it gives the result for next day in CSV format.
e.g: If the date is 31 December 2019 in Rally then in CSV it shows as 1 January 2020. Is it intended behavior? or a bug
Hmmm, is this related to the timezone that you are in? If your workspace timezone is different from your machine timezone, it can throw up oddities like this.
The app might not be timezone aware.

Getting time of tweet

I want to use twitter data for temporal database, but I need the time that the tweet was created.
CreatedAt() only giving the details of account creation date.
Is there any API for getting tweet's time?
You might want to look at created_at. See the twitter dev page:
created_at
String
UTC time when this Tweet was created.
Example:
"created_at":"Wed Aug 27 13:08:45 +0000 2008"

Generic TimeZone According to login user location

I want that all DateTime Objects come from Model may converted to Local of login user. All Datetime are stored in UTC format in Database.
For Example
If someone Create user and CreatedDate is stored in UTC.Now(2014-05-06 01:00PM);
Then someone login from Pakistan and navigate to users view then the DateTime must show as 2014-05-06 06:00PM for last created user.
I know how to convert but which is the best approach to do it. I want to convert all datetime coming from Database into current ..
I saved all My date formats in DateTime.UtcNow
and add 1 column TimeZoneId in DB and check it whenever some results are need to be shown on view or any thing want to manipulate according to timezone of current user.

Teradata SQL Timezone adjustments

I have a database where I can see actions taken by users. These actions have a timestamp. All the timestamps are in EST.
Let's say the action is, downloading content.
I need to find, x amount of users downloaded content y in GMT(these users are in GMT).
I need to find, x amount of users downloaded content y in PST(these users are in PST).
I have the mapping of countries etc. However, I can't find a good query which creates a table with the timezone mappings for the database.
Can anyone give me an idea on how I would do the conversion in SQL and point me in the direction of a query which recreates the timezone mapping table.