0.01
No commit activity in last 3 years
No release in over 3 years
Date formatter with time zone support
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

>= 0
 Project Readme

formatter-date

Format Time/DateTime with time zone offset

Gem Version Build Status Code Climate

Installation

Add this line to your application's Gemfile:

gem 'formatter-date'

And then execute:

$ bundle

Or install it yourself as:

$ gem install formatter-date

Usage

# By default it will use the ISO8601 formatting.
formatter = Formatter::Date.new('Asia/Karachi')
formatter.format(Time.now) # "2015-02-22T03:48:07+05:00"

# Available formats iso8601, xmlschema, jisx0301, rfc3339
formatter = Formatter::Date.new('Asia/Karachi', :jisx0301)
formatter.format(Time.now) # "H27.02.22T03:48:07+05:00"

# You can also provide fractional seconds to be used with formats
formatter = Formatter::Date.new('Asia/Karachi', :iso8601, 2)
formatter.format(Time.now) # 2015-02-22T03:48:07.46+05:00

# Provide a custom string formatting (delegates to strftime)
formatter = Formatter::Date.new('Asia/Karachi', '%FT%T%:z')
formatter.format(Time.now) # "2015-02-22T03:48:07+05:00"

# Get configured time zone identifier
formatter.identifier # "Asia/Karachi"

# Get configured time zone offset
formatter.offset # (5/24)

Contributing

  1. Fork it ( https://github.com/terlar/formatter-date/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request