time_diff 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +8 -0
- data/README.rdoc +8 -0
- data/VERSION +1 -1
- data/lib/en.yml +6 -0
- data/lib/time_diff.rb +3 -1
- data/time_diff.gemspec +3 -2
- metadata +5 -4
data/README
CHANGED
|
@@ -61,3 +61,11 @@ If you give '%d %h' as the third parameter to the Time.diff() method, then the d
|
|
|
61
61
|
=> {:year => 1, :month => 0, :week => 0, :day => 0, :hour => 18, :minute => 0, :second => 30, :diff => '1 year and 18:00:30'}
|
|
62
62
|
> Time.diff(Time.parse('2011-03-06 12:30:00'), Time.parse('2011-03-07 12:30:30'), '%H %N %S')
|
|
63
63
|
=> {:year => 0, :month => 0, :week => 0, :day => 1, :hour => 0, :minute => 0, :second => 30, :diff => '24 hours 0 minute 30 seconds'}
|
|
64
|
+
|
|
65
|
+
== i18n support
|
|
66
|
+
|
|
67
|
+
Add locales for day, days, week, weeks, year, hour, hours, minute, minutes, second, and seconds in your YAML file. For eg:
|
|
68
|
+
|
|
69
|
+
en:
|
|
70
|
+
day: divasam
|
|
71
|
+
days: divasangal
|
data/README.rdoc
CHANGED
|
@@ -62,6 +62,14 @@ If you give '%d %h' as the third parameter to the Time.diff() method, then the d
|
|
|
62
62
|
> Time.diff(Time.parse('2011-03-06 12:30:00'), Time.parse('2011-03-07 12:30:30'), '%H %N %S')
|
|
63
63
|
=> {:year => 0, :month => 0, :week => 0, :day => 1, :hour => 0, :minute => 0, :second => 30, :diff => '24 hours 0 minute 30 seconds'}
|
|
64
64
|
|
|
65
|
+
== i18n support
|
|
66
|
+
|
|
67
|
+
Add translations for day, days, week, weeks, year, hour, hours, minute, minutes, second, and seconds in your YAML file. For eg:
|
|
68
|
+
|
|
69
|
+
en:
|
|
70
|
+
day: divasam
|
|
71
|
+
days: divasangal
|
|
72
|
+
|
|
65
73
|
== Contributing to time_diff
|
|
66
74
|
|
|
67
75
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.3.0
|
data/lib/en.yml
ADDED
data/lib/time_diff.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
require 'active_support/all'
|
|
3
|
+
require 'i18n'
|
|
3
4
|
|
|
4
5
|
class Time
|
|
5
6
|
def self.diff(start_date, end_date, format_string='%y, %M, %w, %d and %h:%m:%s')
|
|
7
|
+
#I18n.load_path += Dir.glob("lib/*.yml")
|
|
6
8
|
start_time = start_date.to_time if start_date.respond_to?(:to_time)
|
|
7
9
|
end_time = end_date.to_time if end_date.respond_to?(:to_time)
|
|
8
10
|
distance_in_seconds = ((end_time - start_time).abs).round
|
|
@@ -65,7 +67,7 @@ class Time
|
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
def Time.pluralize(word, count)
|
|
68
|
-
return count != 1 ? word.pluralize : word
|
|
70
|
+
return count != 1 ? I18n.t(word.pluralize, :default => word.pluralize) : I18n.t(word, :default => word)
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
def Time.remove_format_string_for_zero_components(time_diff_components, format_string)
|
data/time_diff.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{time_diff}
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.3.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = [%q{abhilash}]
|
|
12
|
-
s.date = %q{
|
|
12
|
+
s.date = %q{2012-11-13}
|
|
13
13
|
s.description = %q{It returns a hash file with the difference in terms of year, month, week, day, hour, minute and second}
|
|
14
14
|
s.email = %q{abhidsm@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
"README.rdoc",
|
|
27
27
|
"Rakefile",
|
|
28
28
|
"VERSION",
|
|
29
|
+
"lib/en.yml",
|
|
29
30
|
"lib/time_diff.rb",
|
|
30
31
|
"test/helper.rb",
|
|
31
32
|
"test/test_time_diff.rb",
|
metadata
CHANGED
|
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
version: 0.
|
|
8
|
+
- 3
|
|
9
|
+
- 0
|
|
10
|
+
version: 0.3.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- abhilash
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
18
|
+
date: 2012-11-13 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: activesupport
|
|
@@ -124,6 +124,7 @@ files:
|
|
|
124
124
|
- README.rdoc
|
|
125
125
|
- Rakefile
|
|
126
126
|
- VERSION
|
|
127
|
+
- lib/en.yml
|
|
127
128
|
- lib/time_diff.rb
|
|
128
129
|
- test/helper.rb
|
|
129
130
|
- test/test_time_diff.rb
|