playbook_ui 14.3.0.pre.rc.2 → 14.3.0.pre.rc.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed033686b019c19af40c4b01ac6d465c8df15cc9b26b185927341d59d9eb1e8f
|
4
|
+
data.tar.gz: 934ad51b7ef148eee7fcace86be3aa4888662d47b88221bd31c7fe8e82e2d6a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 618866baee3b09d518ce651ad065d68b9b86fc9b5ce94425f6a80a8279f316a2e2f1b2cb78894680630f0a4a07277f3902ace8a4e1d2507857bada17e688e4a9
|
7
|
+
data.tar.gz: f6ffc3e2fc7dc490358985a564637311bae386f8e67ebf1c00bce9273e2c3cf7b9c3ce4b217502acaa55fd084592f6047162329ac17e69539ace068d92d68690
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<br>
|
9
9
|
|
10
10
|
<%= pb_rails("timestamp", props: {
|
11
|
-
timestamp: DateTime.now,
|
11
|
+
timestamp: DateTime.now - 3.months,
|
12
12
|
variant: "elapsed",
|
13
13
|
show_user: false
|
14
14
|
}) %>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<br>
|
17
17
|
|
18
18
|
<%= pb_rails("timestamp", props: {
|
19
|
-
timestamp: DateTime.now,
|
19
|
+
timestamp: DateTime.now - 320.days,
|
20
20
|
variant: "elapsed",
|
21
21
|
show_user: false,
|
22
22
|
hide_updated: true
|
@@ -27,6 +27,18 @@ module Playbook
|
|
27
27
|
values: %w[default elapsed updated],
|
28
28
|
default: "default"
|
29
29
|
|
30
|
+
# Variables to use with pb_time_ago method
|
31
|
+
SECS_FORTY_FIVE = 45
|
32
|
+
SECS_PER_MIN = 60
|
33
|
+
SECS_PER_HOUR = 60 * SECS_PER_MIN # 3,600 seconds
|
34
|
+
SECS_PER_DAY = 24 * SECS_PER_HOUR # 86,400 seconds
|
35
|
+
SECS_PER_WEEK = 7 * SECS_PER_DAY # 604,800 seconds
|
36
|
+
SECS_PER_26 = 26 * SECS_PER_DAY # 26 days = 2,246,400 seconds
|
37
|
+
SECS_PER_MONTH = 4 * SECS_PER_WEEK # 2,419,200 seconds
|
38
|
+
SECS_PER_YEAR = 12 * SECS_PER_MONTH # 29,030,400 seconds
|
39
|
+
SECS_PER_320 = 320 * SECS_PER_DAY # 320 days = 27,648,000 seconds
|
40
|
+
SECS_PER_CENT = 100 * SECS_PER_YEAR # 3,153,600,000 seconds
|
41
|
+
|
30
42
|
def classname
|
31
43
|
generate_classname("pb_timestamp_kit", variant_class, align)
|
32
44
|
end
|
@@ -73,12 +85,44 @@ module Playbook
|
|
73
85
|
|
74
86
|
def format_elapsed_string
|
75
87
|
user_string = show_user ? " by #{text}" : ""
|
76
|
-
datetime_string = " #{
|
88
|
+
datetime_string = " #{pb_time_ago(pb_date_time.convert_to_timestamp)} ago"
|
89
|
+
datetime_string[1] = hide_updated ? datetime_string[1].upcase : datetime_string[1]
|
77
90
|
updated_string = hide_updated ? "" : "Last updated"
|
78
|
-
|
79
91
|
"#{updated_string}#{user_string}#{datetime_string}"
|
80
92
|
end
|
81
93
|
|
94
|
+
def pb_time_ago(value)
|
95
|
+
time_ago = DateTime.now.to_i - value.to_i
|
96
|
+
case time_ago
|
97
|
+
when (0...SECS_FORTY_FIVE)
|
98
|
+
"a few seconds"
|
99
|
+
when (SECS_FORTY_FIVE...SECS_PER_MIN)
|
100
|
+
"a minute"
|
101
|
+
when (SECS_PER_MIN...SECS_PER_HOUR)
|
102
|
+
time = time_ago / SECS_PER_MIN
|
103
|
+
time == 1 ? "a minute" : "#{time_ago / SECS_PER_MIN} minutes"
|
104
|
+
when (SECS_PER_HOUR...SECS_PER_DAY)
|
105
|
+
time = time_ago / SECS_PER_HOUR
|
106
|
+
time == 1 ? "an hour" : "#{time_ago / SECS_PER_HOUR} hours"
|
107
|
+
when (SECS_PER_DAY...SECS_PER_WEEK)
|
108
|
+
time = time_ago / SECS_PER_DAY
|
109
|
+
time == 1 ? "a day" : "#{time_ago / SECS_PER_DAY} days"
|
110
|
+
when (SECS_PER_WEEK...SECS_PER_26)
|
111
|
+
time = time_ago / SECS_PER_WEEK
|
112
|
+
time == 1 ? "a week" : "#{time_ago / SECS_PER_WEEK} weeks"
|
113
|
+
when (SECS_PER_26...SECS_PER_MONTH)
|
114
|
+
"a month"
|
115
|
+
when (SECS_PER_MONTH...SECS_PER_320)
|
116
|
+
time = time_ago / SECS_PER_MONTH
|
117
|
+
time == 1 ? "a month" : "#{time_ago / SECS_PER_MONTH} months"
|
118
|
+
when (SECS_PER_320...SECS_PER_YEAR)
|
119
|
+
"a year"
|
120
|
+
when (SECS_PER_YEAR...SECS_PER_CENT)
|
121
|
+
time = time_ago / SECS_PER_YEAR
|
122
|
+
time == 1 ? "a year" : "#{time_ago / SECS_PER_YEAR} years"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
82
126
|
def datetime_or_text
|
83
127
|
timestamp ? format_datetime_string : text
|
84
128
|
end
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.3.0.pre.rc.
|
4
|
+
version: 14.3.0.pre.rc.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-09-
|
12
|
+
date: 2024-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|