format_time 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -3
- data/format_time-0.1.1.gem +0 -0
- data/lib/format_time.rb +7 -3
- data/lib/format_time/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df84a7de9a840f95e9403187b9ac984ad95916a1961ed885950415129e554f4
|
4
|
+
data.tar.gz: 017c069bf54741a690f49e5ce7d005330ba3fb3715c75bbdc262e4040f91db7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b457b4488e21df063165ea86b00a2a2f89786faf072eca6d392df35d541acf76ca609556e6f0e7a8274f3daaee737f627c39e54c36efe1ca48afc08a573d0761
|
7
|
+
data.tar.gz: 91535ba7cc22a1f324bf742a2f6ac849a378ce91ba993faeec759c6ef7b03cd5093333c0b3530ef8fc7cdb34c3bcb05a24c8f72a0173ee4e8932852a3c5311de
|
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/format_time`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
@@ -22,7 +20,21 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
Add this line to your class where you gonna use this gem:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
include FormatTime
|
27
|
+
```
|
28
|
+
|
29
|
+
then use it:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
date = Date.parse('2020/01/01')
|
33
|
+
|
34
|
+
format_relative_time(date)
|
35
|
+
|
36
|
+
format_absolute_time(date)
|
37
|
+
```
|
26
38
|
|
27
39
|
## Development
|
28
40
|
|
Binary file
|
data/lib/format_time.rb
CHANGED
@@ -7,11 +7,15 @@ module FormatTime
|
|
7
7
|
# Your code goes here...
|
8
8
|
|
9
9
|
def format_relative_time(time)
|
10
|
+
return '-' if time.nil?
|
11
|
+
|
10
12
|
distance_of_time_in_words_to_now(time, include_seconds: true)
|
11
13
|
end
|
12
14
|
|
13
15
|
def format_absolute_time(time)
|
14
|
-
|
16
|
+
return '-' if time.nil?
|
17
|
+
|
18
|
+
Time.current.year == time.year ? in_year(time) : previous_year(time)
|
15
19
|
end
|
16
20
|
|
17
21
|
private
|
@@ -28,7 +32,7 @@ module FormatTime
|
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
|
-
def
|
32
|
-
I18n.l(time, format: :
|
35
|
+
def previous_year(time)
|
36
|
+
I18n.l(time, format: :previous_year)
|
33
37
|
end
|
34
38
|
end
|
data/lib/format_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: format_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nguyenthanhcong101096
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,22 +28,22 @@ dependencies:
|
|
28
28
|
name: web-console
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.3'
|
34
31
|
- - ">="
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: 3.3.0
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '3.3'
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '3.3'
|
44
41
|
- - ">="
|
45
42
|
- !ruby/object:Gem::Version
|
46
43
|
version: 3.3.0
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.3'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- bin/console
|
76
76
|
- bin/setup
|
77
77
|
- format_time-0.1.0.gem
|
78
|
+
- format_time-0.1.1.gem
|
78
79
|
- format_time.gemspec
|
79
80
|
- lib/format_time.rb
|
80
81
|
- lib/format_time/version.rb
|
@@ -97,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
98
|
- !ruby/object:Gem::Version
|
98
99
|
version: '0'
|
99
100
|
requirements: []
|
100
|
-
|
101
|
-
rubygems_version: 2.7.6
|
101
|
+
rubygems_version: 3.0.3
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: this is the all module for wakuwaku appkication
|