format_time 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dec867b0e636ee72c89d55842bc90efd0e409138d1d939283ed6522ea00b9d91
4
- data.tar.gz: 2a66d91ea53b53d4192f73324110fd96434c176aae85d28a00c1ee0f67b71260
3
+ metadata.gz: 0df84a7de9a840f95e9403187b9ac984ad95916a1961ed885950415129e554f4
4
+ data.tar.gz: 017c069bf54741a690f49e5ce7d005330ba3fb3715c75bbdc262e4040f91db7c
5
5
  SHA512:
6
- metadata.gz: a3c5257e634c28a5adcef7e8adf596e029558bca719c21bd1bbe2862a217ec84be78c704b5540b801092050201494665409fe69b0b12d88370eb71ee7d12b3c4
7
- data.tar.gz: 0de4b36dff0e94f57d2f51ef6a413a9900f26cbc68ac7eeef61a341a676f072351bdb693ead1c190c97d81a4a2419dcccdd5d619e610b82ddafd9bab55ab5a14
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
- TODO: Write usage instructions here
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
@@ -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
- Time.current.year == time.year ? in_year(time) : prevous_year(time)
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 prevous_year(time)
32
- I18n.l(time, format: :prevous_year)
35
+ def previous_year(time)
36
+ I18n.l(time, format: :previous_year)
33
37
  end
34
38
  end
@@ -1,3 +1,3 @@
1
1
  module FormatTime
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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: 2019-11-19 00:00:00.000000000 Z
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
- rubyforge_project:
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