time_compact 0.0.1 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +33 -3
- data/lib/time_compact/version.rb +1 -1
- data/lib/time_compact.rb +4 -4
- data/test/test_time_compact.rb +2 -2
- data/time_compact.gemspec +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7154fa79a650c2616e1e12e290397e0fdb208ee
|
4
|
+
data.tar.gz: 6b0edc90a8bac84512dfc4f4917f497392b21e19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc5126f0138f864bcd32f11d8fd18c74823b3c8c4a5508ba8c7ecb4767fa2161b17844eeeb0a86d592b3e4e09cefd1cd433c9e1d7437a00e42bfc668f3f4fecb
|
7
|
+
data.tar.gz: 3aa51864ac2f9f632c6953dfade2f545755ddd045fb9b9a31e1f05ad9b27f385a6a99d9797a6119f7765308a5535444b32b389265e2c5aef20c0258930afa21f
|
data/README.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# TimeCompact
|
2
2
|
|
3
|
-
|
3
|
+
Displays time compactly.
|
4
|
+
|
5
|
+
for example:
|
6
|
+
|
7
|
+
# default locale
|
8
|
+
2014/1/2 # when other year.
|
9
|
+
1/2 # when same year.
|
10
|
+
8:16 # when same day.
|
11
|
+
|
12
|
+
# 日本語ロケール
|
13
|
+
2014年1月2日 # 違う年の時
|
14
|
+
1月2日 # 同じ年の時
|
15
|
+
8時16分 # 同じ日の時
|
4
16
|
|
5
17
|
## Installation
|
6
18
|
|
@@ -18,11 +30,29 @@ Or install it yourself as:
|
|
18
30
|
|
19
31
|
## Usage
|
20
32
|
|
21
|
-
|
33
|
+
require 'time_compact'
|
34
|
+
|
35
|
+
include TimeCompact
|
36
|
+
time_compact Time.new(2014, 1, 1, 0, 0, 0) # => 5/2
|
37
|
+
|
38
|
+
In rails
|
39
|
+
|
40
|
+
<%= time_compact @post.created_at %>
|
41
|
+
|
42
|
+
You can customize the format.
|
43
|
+
|
44
|
+
# config/locales/en.yml:
|
45
|
+
en:
|
46
|
+
time_compact:
|
47
|
+
same_year: '%{month}/%{day}'
|
48
|
+
same_month: '%{month}/%{day}'
|
49
|
+
same_day: '%{hour}:%{min}'
|
50
|
+
same_hour: '%{min} min'
|
51
|
+
other: '%{year}/%{month}/%{day}'
|
22
52
|
|
23
53
|
## Contributing
|
24
54
|
|
25
|
-
1. Fork it ( https://github.com/
|
55
|
+
1. Fork it ( https://github.com/komagata/time_compact/fork )
|
26
56
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
57
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
58
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/time_compact/version.rb
CHANGED
data/lib/time_compact.rb
CHANGED
@@ -26,7 +26,7 @@ module TimeCompact
|
|
26
26
|
month: time.month,
|
27
27
|
day: time.day,
|
28
28
|
hour: time.hour,
|
29
|
-
min: time.min
|
29
|
+
min: '%02d' % time.min
|
30
30
|
)
|
31
31
|
end
|
32
32
|
else
|
@@ -36,7 +36,7 @@ module TimeCompact
|
|
36
36
|
month: time.month,
|
37
37
|
day: time.day,
|
38
38
|
hour: time.hour,
|
39
|
-
min: time.min
|
39
|
+
min: '%02d' % time.min
|
40
40
|
)
|
41
41
|
end
|
42
42
|
else
|
@@ -46,7 +46,7 @@ module TimeCompact
|
|
46
46
|
month: time.month,
|
47
47
|
day: time.day,
|
48
48
|
hour: time.hour,
|
49
|
-
min: time.min
|
49
|
+
min: '%02d' % time.min
|
50
50
|
)
|
51
51
|
end
|
52
52
|
else
|
@@ -56,7 +56,7 @@ module TimeCompact
|
|
56
56
|
month: time.month,
|
57
57
|
day: time.day,
|
58
58
|
hour: time.hour,
|
59
|
-
min: time.min
|
59
|
+
min: '%02d' % time.min
|
60
60
|
)
|
61
61
|
end
|
62
62
|
end
|
data/test/test_time_compact.rb
CHANGED
@@ -22,7 +22,7 @@ class TestTimeCompact < MiniTest::Unit::TestCase
|
|
22
22
|
Time.new(2014, 1, 1, 0, 0, 0),
|
23
23
|
Time.new(2014, 1, 2, 0, 0, 0)
|
24
24
|
)
|
25
|
-
assert_equal '0:
|
25
|
+
assert_equal '0:00', @object.time_compact(
|
26
26
|
Time.new(2014, 1, 1, 0, 0, 0),
|
27
27
|
Time.new(2014, 1, 1, 1, 0, 0)
|
28
28
|
)
|
@@ -46,7 +46,7 @@ class TestTimeCompact < MiniTest::Unit::TestCase
|
|
46
46
|
Time.new(2014, 1, 1, 0, 0, 0),
|
47
47
|
Time.new(2014, 1, 2, 0, 0, 0)
|
48
48
|
)
|
49
|
-
assert_equal '0時
|
49
|
+
assert_equal '0時00分', @object.time_compact(
|
50
50
|
Time.new(2014, 1, 1, 0, 0, 0),
|
51
51
|
Time.new(2014, 1, 1, 1, 0, 0)
|
52
52
|
)
|
data/time_compact.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = TimeCompact::VERSION
|
9
9
|
spec.authors = ["Masaki Komagata"]
|
10
10
|
spec.email = ["komagata@gmail.com"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
11
|
+
spec.summary = %q{Displays time compactly.}
|
12
|
+
spec.description = %q{Displays time compactly.}
|
13
13
|
spec.homepage = "https://github.com/komagata/time_compact"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_compact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Komagata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description: Displays time compactly.
|
56
56
|
email:
|
57
57
|
- komagata@gmail.com
|
58
58
|
executables: []
|
@@ -94,6 +94,7 @@ rubyforge_project:
|
|
94
94
|
rubygems_version: 2.2.2
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
|
-
summary:
|
97
|
+
summary: Displays time compactly.
|
98
98
|
test_files:
|
99
99
|
- test/test_time_compact.rb
|
100
|
+
has_rdoc:
|