Rails plugin for dead-simple timezone support
Ruby JavaScript
Switch branches/tags
Nothing to show
Pull request Compare This branch is 5 commits ahead, 2 commits behind pjhyett:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
LICENSE
README
init.rb
install.rb

README

Zoned
---

This plugin is the simplest way to add local times to your app.

Usage:

1) Call the javascript function Timezone.set() to set a timezone cookie

    eg: Hook it into the authentication system
    
      Logging in:
      <% form_for @login, { :html => { :onsubmit => "Timezone.set()" } %>
    
      Logging out:
      cookies.delete(:timezone)
      
    eg: Initialize it automatically
    
      window.onload = Timezone.set

2) Use it: <%= z(@post.created_at).strtime("%D") %>

If cookies[:timezone] is set it will convert the time to the user's 
local time, otherwise it will do nothing.

You don't need to have AR save your time in UTC, the plugin will determine 
your server's offset and adjust accordingly.

If you choose to use the zoned method in your active record objects, you will
need to set the Zoned.timezone_offset in a before filter for each request. It
should look something like this:

class ApplicationController < ActionController::Base
  before_filter :set_timezone_offset
  
  protected
    def set_timezone_offset
      Zoned.timezone_offset = cookies['timezone'].to_i
    end
end