a_moment_ago 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/time_ago.rb +46 -2
- metadata +15 -2
- data/lib/locales/en.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9a2dd4696d98518d61a94d6c8e72ef58b7c6edadb1fab6fefe0c525dc255c45
|
4
|
+
data.tar.gz: e25a517657093806dab6c83303309f4f5fabcf7b4dbc10619fd2225c582417d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f95e28b2b6176d0aa6aa0059a1221d232664b41e48713d49588660b1e02c301c235fe75d4fe012e8bc85eff22bd0a4666ac061f4aa5890dd54e7d7d7dfb1f4
|
7
|
+
data.tar.gz: 5eb0be7451312bdcc292c4cc782542fc4c69a1f218cb0cf3496f520bbd887cdf809daeae6a94ca7037f3d28aa329fbd3a6681ac4c9f6168228c1049ee7aec4a0
|
data/lib/time_ago.rb
CHANGED
@@ -1,4 +1,47 @@
|
|
1
|
+
# require "i18n"
|
2
|
+
|
3
|
+
# module TimeAgo
|
4
|
+
# DEFAULT_LOCALE = :en
|
5
|
+
|
6
|
+
# def self.format(time, locale: DEFAULT_LOCALE)
|
7
|
+
# I18n.load_path << Dir[File.expand_path("locales/*.yml", __dir__)]
|
8
|
+
# I18n.default_locale = DEFAULT_LOCALE
|
9
|
+
# I18n.locale = locale
|
10
|
+
|
11
|
+
# distance_in_seconds = (Time.current - time).to_i
|
12
|
+
|
13
|
+
# if distance_in_seconds < 5
|
14
|
+
# I18n.t("time_ago.just_now")
|
15
|
+
# elsif distance_in_seconds < 60
|
16
|
+
# I18n.t("time_ago.seconds_ago", count: distance_in_seconds)
|
17
|
+
# elsif distance_in_seconds < 3600
|
18
|
+
# minutes_ago = (distance_in_seconds / 60).to_i
|
19
|
+
# I18n.t("time_ago.minutes_ago", count: minutes_ago)
|
20
|
+
# elsif distance_in_seconds < 86400
|
21
|
+
# hours_ago = (distance_in_seconds / 3600).to_i
|
22
|
+
# I18n.t("time_ago.hours_ago", count: hours_ago)
|
23
|
+
# elsif distance_in_seconds < 172_800
|
24
|
+
# I18n.t("time_ago.yesterday_at", time: I18n.l(time, format: :time))
|
25
|
+
# else
|
26
|
+
# I18n.t("time_ago.other", time: I18n.l(time, format: :short))
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
# class Time
|
32
|
+
# def self.localized_format(time, locale: TimeAgo::DEFAULT_LOCALE)
|
33
|
+
# TimeAgo.format(time, locale: locale)
|
34
|
+
# end
|
35
|
+
|
36
|
+
# def ago(locale: TimeAgo::DEFAULT_LOCALE)
|
37
|
+
# TimeAgo.format(self, locale: locale)
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
|
41
|
+
|
42
|
+
|
1
43
|
require "i18n"
|
44
|
+
require "active_support/time"
|
2
45
|
|
3
46
|
module TimeAgo
|
4
47
|
DEFAULT_LOCALE = :en
|
@@ -30,10 +73,11 @@ end
|
|
30
73
|
|
31
74
|
class Time
|
32
75
|
def self.localized_format(time, locale: TimeAgo::DEFAULT_LOCALE)
|
33
|
-
TimeAgo
|
76
|
+
TimeAgo::format(time, locale: locale)
|
34
77
|
end
|
35
78
|
|
36
79
|
def ago(locale: TimeAgo::DEFAULT_LOCALE)
|
37
|
-
TimeAgo
|
80
|
+
TimeAgo::format(self, locale: locale)
|
38
81
|
end
|
39
82
|
end
|
83
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: a_moment_ago
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Webster Avosa
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: A gem that formats time intervals as relative dates in Ruby/Rails
|
28
42
|
email:
|
29
43
|
- webster@webstercodes.com
|
@@ -31,7 +45,6 @@ executables: []
|
|
31
45
|
extensions: []
|
32
46
|
extra_rdoc_files: []
|
33
47
|
files:
|
34
|
-
- lib/locales/en.yml
|
35
48
|
- lib/time_ago.rb
|
36
49
|
homepage: https://rubygems.org/gems/a_moment_ago
|
37
50
|
licenses:
|
data/lib/locales/en.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
time_ago:
|
3
|
-
just_now: "just now"
|
4
|
-
seconds_ago:
|
5
|
-
one: "1 second ago"
|
6
|
-
other: "%{count} seconds ago"
|
7
|
-
minutes_ago:
|
8
|
-
one: "1 minute ago"
|
9
|
-
other: "%{count} minutes ago"
|
10
|
-
hours_ago:
|
11
|
-
one: "1 hour ago"
|
12
|
-
other: "%{count} hours ago"
|
13
|
-
yesterday_at: "Yesterday at %{time}"
|
14
|
-
other: "%{time}"
|