usertime-rails

Build Status Coverage Status

A jQuery plugin provides to display time in user's timezone. (See usertime.js)

Dependencies

usertime.js requires moment.js library, please add this library first.

Installation

Add this line to your application's Gemfile:

gem 'usertime-rails'

And then execute:

bundle

Or install it yourself as:

gem install usertime-rails

Usage

Require Javascript

Add the following to /app/assets/javascripts/application.js:

//= require usertime

Helpers

You can use usertime_tag to wrap Time objects.

usertime_tag(Time.now)

It will output:

<usertime>1441099707000</usertime>

You can specify format:

usertime_tag(Time.now, :format => 'lll')

Output:

<usertime format="lll">1441099707000</usertime>

Notice this format is moment.format, not ruby format.

License

The gem is available as open source under the terms of the MIT License.

Contact

The project's website is located at https://github.com/emn178/usertime-rails
Author: Chen, Yi-Cyuan ([email protected])