Uses client-side Javascript to format a datetime instead of the Ruby on Rails server.
Ruby JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
public/javascripts
test
.gitignore
.loadpath
.project
CHANGELOG
MIT-LICENSE
README
Rakefile
TODO
client_date.gemspec
init.rb

README

Hosted at GitHub since May 1, 2008
http://github.com/ryanlowe/client_date

Was hosted at Google Code
http://code.google.com/p/client-date/


= client_date

The client_date Ruby on Rails plugin uses client-side Javascript
to format a date/time in a view instead of the server. The client
is given UTC time for formatting so the server doesn't have to
store which time zone each user is in.

Of course it's also very handy for users that haven't logged in
or do not have a login.

== Installation

  gem install ryanlowe-client_date --source http://gems.github.com/

== Setup

  First include the ClientDate mixin in your ApplicationHelper.

    module ApplicationHelper
      include ClientDate
      ...
    end

  Then copy the javascript code in javascripts/client_date.js to
  your project.  You can do this two ways:

  1. Copy client_date.js to your javascripts/ directory and
     add it to your Rails project using javascript_include_tag.
  2. Copy the code in client_date.js to javascripts/application.js
     which is pulled in by javascript_include_tag :defaults.

== Usage

  In a view you can use:
  
  format_date(date)           # month, day
  format_datetime(date)       # month, day, hour, minute
  format_datetime(date,true)  # month, day, hour, minute, seconds
  
  The date parameter should be a normal Ruby date, like the "datetime" used
  in Rails migrations.
  
  Example:
  
  <p>Created at: <%= format_datetime(post.created_at) %></p>
  
== Customization

  Change how client_date formats dates and times by changing the
  fd() and fdt() Javascript functions.