formatter-date¶ ↑
Format Time/DateTime with time zone offset
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¶ ↑
-
Fork it ( github.com/terlar/formatter-date/fork )
-
Create your feature branch (
git checkout -b my-new-feature
) -
Commit your changes (
git commit -am 'Add some feature'
) -
Push to the branch (
git push origin my-new-feature
) -
Create a new Pull Request