Hi All, I''m having a bit of an issue with time in my application. I''d be inclined to think that it was simply a machine time issue, but, as I''ve run the application on multiple machines, I''m not so sure. Basically, my rails "current time" and my javascript "current time" are anywhere from 3 to 6 seconds apart. Is there any way for me to resolve this? I suppose I could get a capture of each and add or subtract one from the other, but the trouble is that I''m using a timer, and the logic to ensure that the value doesn''t re-change after the initial setting could get out of hand. Are there perhaps any "static var" additions to Javascript? Thanks in advance for any suggestions. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, 20 Jun 2008, gberz3 wrote:> I''m having a bit of an issue with time in my application. I''d be > inclined to think that it was simply a machine time issue, but, as > I''ve run the application on multiple machines, I''m not so sure. > > Basically, my rails "current time" and my javascript "current time" > are anywhere from 3 to 6 seconds apart. Is there any way for me to > resolve this? > > I suppose I could get a capture of each and add or subtract one from > the other, but the trouble is that I''m using a timer, and the logic to > ensure that the value doesn''t re-change after the initial setting > could get out of hand. Are there perhaps any "static var" additions > to Javascript?Do you really expect your browser and the remote server clocks to be exactly in sync? -- A --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yes, if they''re running on the same system. In a distributed system, not at all, but it would be nice if it were *consistently* out of sync. Ya know? Still I need a mechanism to right the wrong. Thoughts? On Jun 20, 4:07 pm, Eno <symb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, 20 Jun 2008, gberz3 wrote: > > I''m having a bit of an issue with time in my application. I''d be > > inclined to think that it was simply a machine time issue, but, as > > I''ve run the application on multiple machines, I''m not so sure. > > > Basically, my rails "current time" and my javascript "current time" > > are anywhere from 3 to 6 seconds apart. Is there any way for me to > > resolve this? > > > I suppose I could get a capture of each and add or subtract one from > > the other, but the trouble is that I''m using a timer, and the logic to > > ensure that the value doesn''t re-change after the initial setting > > could get out of hand. Are there perhaps any "static var" additions > > to Javascript? > > Do you really expect your browser and the remote server clocks to be > exactly in sync? > > -- > A--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-22 09:34 UTC
Re: Rails "clock" and Javascript "clock" seconds apart.
On 21 Jun 2008, at 02:16, gberz3 wrote:> > Yes, if they''re running on the same system. In a distributed system, > not at all, but it would be nice if it were *consistently* out of > sync. Ya know? Still I need a mechanism to right the wrong. > Thoughts? >What exactly are you doing? Is the time difference just the difference between when you evaluated Time.now in your app and when the page finished loading and the browser started to run the javascript?> On Jun 20, 4:07 pm, Eno <symb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On Fri, 20 Jun 2008, gberz3 wrote: >>> I''m having a bit of an issue with time in my application. I''d be >>> inclined to think that it was simply a machine time issue, but, as >>> I''ve run the application on multiple machines, I''m not so sure. >> >>> Basically, my rails "current time" and my javascript "current time" >>> are anywhere from 3 to 6 seconds apart. Is there any way for me to >>> resolve this? >> >>> I suppose I could get a capture of each and add or subtract one from >>> the other, but the trouble is that I''m using a timer, and the >>> logic to >>> ensure that the value doesn''t re-change after the initial setting >>> could get out of hand. Are there perhaps any "static var" additions >>> to Javascript? >> >> Do you really expect your browser and the remote server clocks to be >> exactly in sync? >> >> -- >> A > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 22, 5:34 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 21 Jun 2008, at 02:16, gberz3 wrote: > > > > > Yes, if they''re running on the same system. In a distributed system, > > not at all, but it would be nice if it were *consistently* out of > > sync. Ya know? Still I need a mechanism to right the wrong. > > Thoughts? > > What exactly are you doing? Is the time difference just the difference > between when you evaluated Time.now in your app and when the page > finished loading and the browser started to run the javascript?No, the difference is actually between the Javascript "Time.now", and the rails property "Object.created_at". What I did was just base the time on the server completely and worked some code like the following: //SET SOME OTHER VALUES IN RAILS EARLIER <script type="text/javascript"> function clockwatch() if (typeof initial_time == ''undef''){ initial_time = <%= Time.new%> } initial_time++ //perform my subtractions, etc here } </script> My initial problem was the seeming lack of Javascript "static" types. But using that allowed me to sort of create a static object. Anyway, basing the time strictly on the server worked. One question: If you use RJS does it get re-evaluated on each iteration, or does it get "pumped out" once-for-all-time like regular Javascript? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-22 15:56 UTC
Re: Rails "clock" and Javascript "clock" seconds apart.
> > One question: If you use RJS does it get re-evaluated on each > iteration, or does it get "pumped out" once-for-all-time like regular > Javascript?evaluated on each request. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---