-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tomato times in local time #8
Comments
this is a js setting cookie with your browser timezone: https://github.com/potomak/tomatoes/blob/develop/public/javascripts/time_zone.js and this is the filter using cookie value to set the correct timezone: https://github.com/potomak/tomatoes/blob/develop/app/controllers/application_controller.rb#L13 where do you think I'm wrong? |
I do think there's something wrong in your tz offset calculation - I am in US Central, and we are currently observing DST so should be at UTC-5, but the cookie that's being set makes my timezone UTC-6, which matches what I'm seeing in the timestamps |
indeed - since you're using the max of january's tz offset and july's offset you're always goign to get 360 for my timezone (at least as I read things). Any reason why you're not just using new Date().getTimezoneOffset()? I'll stick that into my fork tonight and see if it works.... |
You can't use Example 1: This happens because Example 2: What do you think about? |
OK, I see the issue. That said, is having ruby select the right timezone important for any reason other than displaying the local times? In other words, does it matter that ruby is selecting COT instead of CST for me as long as the times displayed are correct? From what I can tell (and I'm only starting to learn ruby) you're using it primarily to set created time in the db. I created a tomato in my db last night which has the created at of "created_at" : "Tue Sep 20 2011 22:20:32 GMT-0500 (CST)", which is correct right now - I am at GMT-0500. What am I missing? |
Mongoid stores dates in production using UTC. In Mongoid configuration I set |
I guess I'm just dense because I'm still not seeing the problem with using the timezone determined by getTimezoneOffset. The dates are getting converted to the dictated offset on the way into the db, right? So a tomato I created yesterday at 12:00-12:25 my time will still show as 12:00-12:25 GMT-0500 after the DST switch, right? It seems like all of the timezone manipulations are just to get the right offset for grouping of tomatoes into days and to render the local time on the page. If that's the case what's important is really the offset and not the timezone per se, so it doesn't really matter what named timezone I am in. Perhaps there's something in the Freckle integration that makes the actual timezone important? If there's some other aspect of the functionality of Tomatoes that makes the named TZ important I would like to know; I don't understand how its's important, but would love to learn more about it.... All of which said - the hour difference isn't really that big of a deal for me - I'm not using the times for anything of real import, so if there's a side effect that I'm not considering then it's not worth a lot of effort, at least not for me. |
You're not right, they're not converted into the db, they're converted only when they become ruby objects (mongoid models). Into the DB you should put only UTC dates! Cori, we need a test case, or real examples, otherwise we're talking about nothing. Yes, timezone manipulations are just to get the right offsets in views, they're not concerning the Freckle connection (also because Freckle API and support suck) anyway I'd really like to resolve this issue. |
Not sure exactly how exactly to define the test case, because I can't force the correct behavior. The timezone cookie setter will always set to 360 for my timezone - the max of Jan 1's offset (-360) and July 1's offset (-300). That's correct during CST (US Central Standard Time) but incorrect during CDT (US Central Daylight Time). My supposition is that when my clock flips to CST in November Tomatoes will show the correct times, but for right now they are 1 hour behind. I saw your tweet, perhaps another US user will come forward.... |
Ok! I've finally got it! Some notes to explain the problem:
Your current time zone offset is 300 (using DST), but the standard offset is 360. The algorithm chooses the maximum between 300 and 360, so it chooses 360. The problem is The only solution it to ask people to set their time zone manually. |
uff da. I see what you're saying about the max and after reading around a little I see what you're doing with the timezone getter - essentially you want the standard offset, which is the greater of standard time or dst (exemplified by the client offset on jan 1 vs jul 1). Then you're using ActiveSupport::TimeZone to figure out if the user is in DST or not. Thanks for clarifying. Always good to learn something new.... |
I dont know how it works jet, (I'm just about to study the app code) but reading this thread I have a question: I understand that you try to get the right timezone from the user, to use it when saving the tomato inside the application and make it have the right time, but why dont you just take the actual hour from the user browser with javascript, and save the tomato with that information instead of calculating it with hour the server hour and the timezone calculation ? |
Just think about software you're using right now: why does Twitter ask you for your timezone? |
Why would it lead to worst data manipulation processes ? You can clearly get the exact hour from the user browser and use it as the tomato datetime, right ? |
Maybe using the IP's timezone? :) try: http://api.ipinfodb.com/v3/ip-city/?key={{API_KEY}}&ip=190.188.221.244&timezone=true returns: OK;;190.188.221.244;AR;ARGENTINA;BUENOS AIRES;LA PLATA;-;-34.931;-57.949;-03:00 |
Looks like the timestamps for tomatoes are behind by an hour in my tz. Could be a summer time thing...
The text was updated successfully, but these errors were encountered: