dotiw 3.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +45 -0
  3. data/.gitignore +2 -1
  4. data/.rspec +2 -0
  5. data/Appraisals +19 -0
  6. data/CHANGELOG.md +29 -0
  7. data/CONTRIBUTING.md +34 -0
  8. data/Gemfile +2 -0
  9. data/MIT-LICENSE +1 -1
  10. data/README.markdown +139 -70
  11. data/Rakefile +3 -1
  12. data/dotiw.gemspec +22 -17
  13. data/gemfiles/.bundle/config +2 -0
  14. data/gemfiles/rails_4.gemfile +9 -0
  15. data/gemfiles/rails_5.0.gemfile +9 -0
  16. data/gemfiles/rails_5.1.gemfile +9 -0
  17. data/gemfiles/rails_5.2.gemfile +9 -0
  18. data/gemfiles/rails_6.0.gemfile +9 -0
  19. data/lib/dotiw.rb +31 -13
  20. data/lib/dotiw/action_view/helpers/date_helper.rb +24 -0
  21. data/lib/dotiw/locale/ar.yml +53 -0
  22. data/lib/dotiw/locale/da.yml +23 -0
  23. data/lib/dotiw/locale/fr.yml +25 -0
  24. data/lib/dotiw/locale/id.yml +25 -0
  25. data/lib/dotiw/locale/ko.yml +25 -0
  26. data/lib/dotiw/locale/pl.yml +7 -0
  27. data/lib/dotiw/locale/pt-BR.yml +25 -0
  28. data/lib/dotiw/locale/vi.yml +25 -0
  29. data/lib/dotiw/locale/zh-CN.yml +25 -0
  30. data/lib/dotiw/methods.rb +93 -0
  31. data/lib/dotiw/time_hash.rb +65 -38
  32. data/lib/dotiw/version.rb +2 -2
  33. data/spec/lib/dotiw_spec.rb +264 -159
  34. data/spec/lib/i18n/ar.yml +2 -0
  35. data/spec/lib/i18n/da.yml +2 -0
  36. data/spec/lib/i18n/de.yml +2 -0
  37. data/spec/lib/i18n/en.yml +2 -0
  38. data/spec/lib/i18n/es.yml +3 -0
  39. data/spec/lib/i18n/fr.yml +2 -0
  40. data/spec/lib/i18n/id.yml +2 -0
  41. data/spec/lib/i18n/it.yml +3 -0
  42. data/spec/lib/i18n/ja.yml +2 -0
  43. data/spec/lib/i18n/ko.yml +2 -0
  44. data/spec/lib/i18n/nb.yml +2 -0
  45. data/spec/lib/i18n/nl.yml +2 -0
  46. data/spec/lib/i18n/pl.yml +2 -0
  47. data/spec/lib/i18n/pt-BR.yml +2 -0
  48. data/spec/lib/i18n/ru.yml +5 -0
  49. data/spec/lib/i18n/vi.yml +22 -0
  50. data/spec/lib/i18n/zh-CN.yml +2 -0
  51. data/spec/spec_helper.rb +2 -9
  52. metadata +110 -21
  53. data/.travis.yml +0 -5
  54. data/lib/dotiw/action_view_ext/helpers/date_helper.rb +0 -103
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a3a8e04cc6ea63912711e2a1fc4394513eaad843
4
- data.tar.gz: 04fe6b44d6d5b34cdf2949bd44eebfbf055743bd
2
+ SHA256:
3
+ metadata.gz: 6c3178c4c07b2647581895e344418e9ce40e3da5d9e3cc1fda714f9817b852e8
4
+ data.tar.gz: cef2e7944c792c501181789e3ed9f0155e12be6954e40664f495bcb298f40709
5
5
  SHA512:
6
- metadata.gz: 8fa225fca7fcf4f3e7aa8a948ca0b5080f780e0b1f16450f9456b052e3f11aab5828390f64278f239491cbb4e0afb131283cf2277ae8eb0d17b127b560410b51
7
- data.tar.gz: 4d932e653886ebfbf9ee830bcf70aa817ef608d0759244eee579c19a4f9429583f79a5254c7d6d2b17a0aa49b53198bc9e320afc99642eeae0e85bd858a4924b
6
+ metadata.gz: 2db64efc0d3189bca7be013a3faff83820392bcfc69bf111497ea3543d67eba53f3792f62e6c43b1d39b73a6d6fb32811b6ae4f511f04c19d069283cdd18f355
7
+ data.tar.gz: a9bae3a175fada3623c8275abec2052e377716db914dadd0b2908a33fbff67fa95191062cb37cb20d15a90478b61ddc9647140d04dc37f0be73fd44b833e7957
@@ -0,0 +1,45 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ include:
18
+ - ruby-version: 2.5.x
19
+ - ruby-version: 2.6.x
20
+ - ruby-version: 2.4.x
21
+ bundler-version: 1.17.3
22
+ gemfile: gemfiles/rails_4.gemfile
23
+ - ruby-version: 2.6.x
24
+ gemfile: gemfiles/rails_5.0.gemfile
25
+ - ruby-version: 2.6.x
26
+ gemfile: gemfiles/rails_5.1.gemfile
27
+ - ruby-version: 2.6.x
28
+ gemfile: gemfiles/rails_5.2.gemfile
29
+ - ruby-version: 2.6.x
30
+ gemfile: gemfiles/rails_6.0.gemfile
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - name: Set up Ruby
34
+ uses: actions/setup-ruby@v1
35
+ with:
36
+ ruby-version: ${{ matrix.ruby-version }}
37
+ - name: Build and test
38
+ env:
39
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
40
+ BUNDLER: ${{ matrix.bundler-version }}
41
+ run: |
42
+ gem uninstall bundler
43
+ gem install bundler -v ${BUNDLER:-2.1.4}
44
+ bundle install --jobs 4 --retry 3
45
+ bundle exec rake
data/.gitignore CHANGED
@@ -2,4 +2,5 @@ tmp
2
2
  pkg
3
3
  spec/fixtures/database.yml
4
4
  .rvmrc
5
- Gemfile.lock
5
+ Gemfile.lock
6
+ gemfiles/*.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,19 @@
1
+ appraise 'rails_4' do
2
+ gem 'rails', '~> 4.0'
3
+ end
4
+
5
+ appraise 'rails_5.0' do
6
+ gem 'rails', '~> 5.0.0'
7
+ end
8
+
9
+ appraise 'rails_5.1' do
10
+ gem 'rails', '~> 5.1.0'
11
+ end
12
+
13
+ appraise 'rails_5.2' do
14
+ gem 'rails', '~> 5.2.0'
15
+ end
16
+
17
+ appraise 'rails_6.0' do
18
+ gem 'rails', '~> 6.0.0'
19
+ end
@@ -0,0 +1,29 @@
1
+ ## 5.1.0 (2020/08/05)
2
+
3
+ * [#111](https://github.com/radar/distance_of_time_in_words/pull/111): Fix: `NoMethodError` when calling `ActionController::Base.helpers.distance_of_time_in_words` - [@denisahearn](https://github.com/denisahearn).
4
+ * [#106](https://github.com/radar/distance_of_time_in_words/pull/106): Add Vietnamese language support - [@runlevel5 ](https://github.com/runlevel5).
5
+
6
+ ## 5.0.0 (2020/05/07)
7
+
8
+ * [#105](https://github.com/radar/distance_of_time_in_words/pull/105): Support for Ruby w/o Rails - [@dblock](https://github.com/dblock).
9
+ * [#108](https://github.com/radar/distance_of_time_in_words/pull/108): Fix negative weeks - [@ivanovaleksey](https://github.com/ivanovaleksey).
10
+
11
+ ## 4.0.1 (2018/06/01)
12
+
13
+ ## 3.1.1 (2016/03/08)
14
+
15
+ ## 3.1.0 (2016/03/07)
16
+
17
+ * [#68](https://github.com/radar/dotiw/pull/68): Add support for weeks - [@lauranjansen](https://github.com/lauranjansen).
18
+ * [#69](https://github.com/radar/dotiw/pull/69): Add Indonesian language support - [@avidmaulanas](https://github.com/avidmaulanas).
19
+ * [#70](https://github.com/radar/dotiw/pull/70): Add French language support - [@geo1004](https://github.com/geo1004).
20
+ * [#72](https://github.com/radar/dotiw/pull/72): Add Danish language support - [@kaspernj](https://github.com/kaspernj).
21
+ * [#71](https://github.com/radar/dotiw/pull/71): Update bundler and ruby versions for Travis CI - [@lauranjansen](https://github.com/lauranjansen).
22
+
23
+ ## 3.0.1 (2015/04/09)
24
+
25
+ ## 3.0 (2015/04/09)
26
+
27
+ ## 0.2.4 (2009/10/18)
28
+
29
+ * Initial public release - [@radar](https://github.com/radar).
@@ -0,0 +1,34 @@
1
+ DOTIW is an open source project and we encourage contributions.
2
+
3
+ ## Filing an issue
4
+
5
+ When filing an issue on the DOTIW project, please provide these details:
6
+
7
+ * A comprehensive list of steps to reproduce the issue.
8
+ * What you're *expecting* to happen compared with what's *actually* happening.
9
+ * Your application's complete `Gemfile.lock`, and `Gemfile.lock` as text in a [Gist](https://gist.github.com) (*not as an image*)
10
+ * Any relevant stack traces ("Full trace" preferred)
11
+
12
+ In 99% of cases, this information is enough to determine the cause and solution
13
+ to the problem that is being described.
14
+
15
+ Please remember to format code using triple backticks (\`) so that it is neatly
16
+ formatted when the issue is posted.
17
+
18
+ ## Pull requests
19
+
20
+ We gladly accept pull requests to add documentation, fix bugs and, in some circumstances,
21
+ add new features to DOTIW.
22
+
23
+ Here's a quick guide:
24
+
25
+ 1. Fork the repo.
26
+
27
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
28
+ to know that you have a clean slate.
29
+
30
+ 3. Create new branch then make changes and add tests for your changes. Only
31
+ refactoring and documentation changes require no new tests. If you are adding
32
+ functionality or fixing a bug, we need tests!
33
+
34
+ 4. Push to your fork and submit a pull request.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Ryan Bigg
1
+ Copyright (c) 2009-2020 Ryan Bigg
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,54 +1,83 @@
1
- # dotiw [![](https://travis-ci.org/radar/dotiw.png)](https://travis-ci.org/radar/dotiw)
1
+ # dotiw ![Ruby](https://github.com/radar/distance_of_time_in_words/workflows/Ruby/badge.svg)
2
2
 
3
- dotiw is a gem for Rails that overrides the default `distance_of_time_in_words` and provides a more accurate output. Do you crave accuracy down to the second? So do I. That's why I made this gem. Take this for a totally kickass example:
3
+ The `dotiw` library that adds `distance_of_time_in_words` to any Ruby project, or overrides the default implementation in Rails with more accurate output.
4
+
5
+ Do you crave accuracy down to the second? So do I. That's why I made this gem.
6
+
7
+ ## Install
8
+
9
+ Add to your `Gemfile`.
10
+
11
+ ```ruby
12
+ gem 'dotiw'
13
+ ```
14
+
15
+ Run `bundle install`.
16
+
17
+ ### Pure Ruby
18
+
19
+ ```ruby
20
+ require 'dotiw'
21
+
22
+ include DOTIW::Methods
23
+ ```
24
+
25
+ ### Rails
26
+
27
+ ```ruby
28
+ require 'dotiw'
29
+
30
+ include ActionView::Helpers::DateHelper
31
+ include ActionView::Helpers::TextHelper
32
+ include ActionView::Helpers::NumberHelper
33
+ ```
34
+
35
+ ## distance\_of\_time\_in\_words
36
+
37
+ Take this for a totally kick-ass example:
38
+
39
+ ```ruby
40
+ >> distance_of_time_in_words(Time.now, Time.now + 1.year + 2.months + 3.weeks + 4.days + 5.hours + 6.minutes + 7.seconds, true)
41
+ => "1 year, 2 months, 3 weeks, 4 days, 5 hours, 6 minutes, and 7 seconds"
42
+ ```
4
43
 
5
- >> distance_of_time_in_words(Time.now, Time.now + 1.year + 2.months + 3.days + 4.hours + 5.minutes + 6.seconds, true)
6
- => "1 year, 2 months, 3 days, 4 hours, 5 minutes, and 6 seconds"
7
-
8
44
  Also if one of the measurement is zero it will not output it:
9
45
 
10
- >> distance_of_time_in_words(Time.now, Time.now + 1.year + 2.months + 4.hours + 5.minutes + 6.seconds, true)
11
- => "1 year, 2 months, 4 hours, 5 minutes, and 6 seconds"
12
-
46
+ ```ruby
47
+ >> distance_of_time_in_words(Time.now, Time.now + 1.year + 2.months + 5.hours + 6.minutes + 7.seconds, true)
48
+ => "1 year, 2 months, 4 days, 6 minutes, and 7 seconds"
49
+ ```
50
+
13
51
  Better than "about 1 year", am I right? Of course I am.
14
52
 
15
53
  "But Ryan!", you say, "What happens if the time is only in seconds but because of the default the seconds aren't shown? Won't it be blank?"
16
54
  "No!" I triumphantly reply:
17
55
 
18
- >> distance_of_time_in_words(Time.now, Time.now + 1.second, false)
19
- => "1 second"
56
+ ```ruby
57
+ >> distance_of_time_in_words(Time.now, Time.now + 1.second, false)
58
+ => "1 second"
59
+ ```
20
60
 
21
61
  The third argument for this method is whether or not to include seconds. By default this is `false` (because in Rails' `distance_of_time_in_words` it is), you can turn it on though by passing `true` as the third argument:
22
62
 
23
- >> distance_of_time_in_words(Time.now, Time.now + 1.year + 1.second, true)
24
- => "1 year, and 1 second"
63
+ ```ruby
64
+ >> distance_of_time_in_words(Time.now, Time.now + 1.year + 1.second, true)
65
+ => "1 year, and 1 second"
66
+ ```
25
67
 
26
- Yes this could just be merged into the options hash but I'm leaving it here to ensure "backwards-compatibility",
27
- because that's just an insanely radical thing to do. \m/
68
+ Yes this could just be merged into the options hash but I'm leaving it here to ensure "backwards-compatibility", because that's just an insanely radical thing to do. \m/
28
69
 
29
70
  The last argument is an optional options hash that can be used to manipulate behavior and (which uses `to_sentence`).
30
71
 
31
72
  Don't like having to pass in `Time.now` all the time? Then use `time_ago_in_words` which also will *rock your
32
73
  world*:
33
74
 
34
- >> time_ago_in_words(Time.now + 3.days + 1.second)
35
- => "3 days, and 1 second"
36
-
37
- Oh, and did I mention it supports I18n? Oh yeah. Rock on!
38
-
39
- ## Install
40
-
41
- Install it as a gem:
42
-
43
75
  ```ruby
44
- gem 'dotiw'
76
+ >> time_ago_in_words(Time.now + 3.days + 1.second)
77
+ => "3 days, and 1 second"
45
78
  ```
46
79
 
47
- Or from GitHub:
48
-
49
- ```ruby
50
- gem 'dotiw', github: 'radar/dotiw'
51
- ```
80
+ Oh, and did I mention it supports I18n? Oh yeah. Rock on!
52
81
 
53
82
  ### Options
54
83
 
@@ -56,10 +85,12 @@ gem 'dotiw', github: 'radar/dotiw'
56
85
 
57
86
  You can pass in a locale and it'll output it in whatever language you want (provided you have translations, otherwise it'll default to your app's default locale (the `config.i18n.default_locale` you have set in `/config/application.rb`):
58
87
 
59
- >> distance_of_time_in_words(Time.now, Time.now + 1.minute, false, :locale => :es)
60
- => "1 minuto"
61
-
62
- This will also be passed to `to_sentence`
88
+ ```ruby
89
+ >> distance_of_time_in_words(Time.now, Time.now + 1.minute, false, locale: :es)
90
+ => "1 minuto"
91
+ ```
92
+
93
+ This will also be passed to `to_sentence`.
63
94
 
64
95
  #### :vague
65
96
 
@@ -67,46 +98,60 @@ Specify this if you want it to use the old `distance_of_time_in_words`. The valu
67
98
 
68
99
  #### :accumulate_on
69
100
 
70
- Specifies the maximum output unit which will accumulate all the surplus. Say you set it to seconds and your time difference is of 2 minutes then the output would be 120 seconds. Here's a code example:
101
+ Specifies the maximum output unit which will accumulate all the surplus. Say you set it to seconds and your time difference is of 2 minutes then the output would be 120 seconds.
71
102
 
72
- >> distance_of_time_in_words(Time.now, Time.now + 2.hours + 70.seconds, true, :accumulate_on => :minutes)
73
- => "121 minutes and 10 seconds"
103
+ ```ruby
104
+ >> distance_of_time_in_words(Time.now, Time.now + 2.hours + 70.seconds, true, accumulate_on: :minutes)
105
+ => "121 minutes and 10 seconds"
106
+ ```
74
107
 
75
108
  #### :only
76
109
 
77
110
  Only want a specific measurement of time? No problem!
78
111
 
79
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute, false, :only => :minutes)
80
- => "1 minute"
112
+ ```ruby
113
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute, false, only: :minutes)
114
+ => "1 minute"
115
+ ```
81
116
 
82
117
  You only want some? No problem too!
83
118
 
84
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.day + 1.minute, false, :only => [:minutes, :hours])
85
- => "1 hour and 1 minute"
119
+ ```ruby
120
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.day + 1.minute, false, only: [:minutes, :hours])
121
+ => "1 hour and 1 minute"
122
+ ```
86
123
 
87
124
  #### :except
88
125
 
89
126
  Don't want a measurement of time? No problem!
90
127
 
91
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute, false, :except => :minutes)
92
- => "1 hour"
128
+ ```ruby
129
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute, false, except: :minutes)
130
+ => "1 hour"
131
+ ```
93
132
 
94
133
  Culling a whole group of measurements of time:
95
134
 
96
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.day + 1.minute, false, :except => [:minutes, :hours])
97
- => "1 day"
98
-
135
+ ```ruby
136
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.day + 1.minute, false, except: [:minutes, :hours])
137
+ => "1 day"
138
+ ```
139
+
99
140
  #### :highest\_measure\_only
100
141
 
101
142
  For times when Rails `distance_of_time_in_words` is not precise enough and `DOTIW` is too precise. For instance, if you only want to know the highest time part (measure) that elapsed between two dates.
102
143
 
103
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute + 1.second, true, :highest_measure_only => true)
104
- => "1 hour"
144
+ ```ruby
145
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute + 1.second, true, highest_measure_only: true)
146
+ => "1 hour"
147
+ ```
105
148
 
106
149
  Notice how minutes and seconds were removed from the output. Another example:
107
150
 
108
- >> distance_of_time_in_words(Time.now, Time.now + 1.minute + 1.second, true, :highest_measure_only => true)
109
- => "1 minute"
151
+ ```ruby
152
+ >> distance_of_time_in_words(Time.now, Time.now + 1.minute + 1.second, true, highest_measure_only: true)
153
+ => "1 minute"
154
+ ```
110
155
 
111
156
  Minutes are the highest measure, so seconds were discarded from the output.
112
157
 
@@ -114,58 +159,81 @@ Minutes are the highest measure, so seconds were discarded from the output.
114
159
 
115
160
  When you want variable precision from `DOTIW`:
116
161
 
117
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute + 1.second, true, :highest_measures => 2)
118
- => "1 hour and 1 minute"
162
+ ```ruby
163
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute + 1.second, true, highest_measures: 2)
164
+ => "1 hour and 1 minute"
165
+ ```
119
166
 
120
167
  #### :words_connector
121
168
 
122
- **This is an option for `to_sentence`, defaults to ', '**
169
+ This is an option for `to_sentence`, defaults to ', '.
123
170
 
124
171
  Using something other than a comma:
125
172
 
126
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute + 1.second, true, :words_connector => ' - ')
127
- => "1 hour - 1 minute, and 1 second"
128
-
173
+ ```ruby
174
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute + 1.second, true, words_connector: ' - ')
175
+ => "1 hour - 1 minute, and 1 second"
176
+ ```
177
+
129
178
  #### :two\_words\_connector
130
179
 
131
- **This is an option for `to_sentence`, defaults to ' and '**
180
+ This is an option for `to_sentence`, defaults to ' and '.
132
181
 
133
182
  Using something other than 'and':
134
183
 
135
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute, true, :two_words_connector => ' plus ')
136
- => "1 hour plus 1 minute"
184
+ ```ruby
185
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute, true, two_words_connector: ' plus ')
186
+ => "1 hour plus 1 minute"
187
+ ```
137
188
 
138
- #### :last\_word\_connector
189
+ #### :last\_word\_connector
139
190
 
140
- **This is an option for `to_sentence`, defaults to ', and '**
191
+ This is an option for `to_sentence`, defaults to ', and '.
141
192
 
142
193
  Using something other than ', and':
143
194
 
144
- >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute + 1.second, true, :last_word_connector => ', finally ')
145
- => "1 hour, 1 minute, finally 1 second"
195
+ ```ruby
196
+ >> distance_of_time_in_words(Time.now, Time.now + 1.hour + 1.minute + 1.second, true, last_word_connector: ', finally ')
197
+ => "1 hour, 1 minute, finally 1 second"
198
+ ```
146
199
 
147
200
  ## distance\_of\_time
148
201
 
149
202
  If you have simply a number of seconds you can get the "stringified" version of this by using `distance_of_time`:
150
203
 
151
- >> distance_of_time(300)
152
- => "5 minutes"
204
+ ```ruby
205
+ >> distance_of_time(300)
206
+ => "5 minutes"
207
+ ```
153
208
 
154
209
  ## distance\_of\_time\_in\_words\_hash
155
210
 
156
211
  Don't like any format you're given? That's cool too! Here, have an indifferent hash version:
157
212
 
158
- >> distance_of_time_in_words_hash(Time.now, Time.now + 1.year + 2.months + 3.days + 4.hours + 5.minutes + 6.seconds)
159
- => {:days => 3, :seconds => 6, :minutes => 5, :years => 1, :hours => 4, :months => 2}
213
+ ```ruby
214
+ >> distance_of_time_in_words_hash(Time.now, Time.now + 1.year + 2.months + 3.weeks + 4.days + 5.hours + 6.minutes + 7.seconds)
215
+ => { days: 4, weeks: 3, seconds: 7, minutes: 6, years: 1, hours: 5, months: 2 }
216
+ ```
160
217
 
161
218
  Indifferent means that you can access all keys by their `String` or `Symbol` version.
162
-
219
+
163
220
  ## distance\_of\_time\_in\_percent
164
221
 
165
- If you want to calculate a distance of time in percent, use `distance_of_time_in_percent`. The first argument is the beginning time, the second argument the "current" time and the third argument is the end time. This method takes the same options as [`number_with_precision`](http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_precision).
222
+ This method is only available with Rails ActionView.
223
+
224
+ If you want to calculate a distance of time in percent, use `distance_of_time_in_percent`. The first argument is the beginning time, the second argument the "current" time and the third argument is the end time.
225
+
226
+ ```ruby
227
+ >> distance_of_time_in_percent("04-12-2009".to_time, "29-01-2010".to_time, "04-12-2010".to_time)
228
+ => '15%'
229
+ ```
230
+
231
+ This method takes the same options as [`number_with_precision`](http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_precision).
166
232
 
167
- distance_of_time_in_percent("04-12-2009".to_time, "29-01-2010".to_time, "04-12-2010".to_time, options)
168
-
233
+ ```ruby
234
+ >> distance_of_time_in_percent("04-12-2009".to_time, "29-01-2010".to_time, "04-12-2010".to_time, precision: 1)
235
+ => '15.3%'
236
+ ```
169
237
 
170
238
  ## Contributors
171
239
 
@@ -173,3 +241,4 @@ If you want to calculate a distance of time in percent, use `distance_of_time_in
173
241
  * [Derander](http://github.com/derander) - correct Spanish translations
174
242
  * [DBA](http://github.com/dba) - commits leading up to the 0.7 release
175
243
  * [Sija](http://github.com/Sija) - rails 4 support, v2.0 release
244
+ * [dblock](http://github.com/dblock) - Ruby w/o Rails support