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: f47148e7be42c7c8683dd6ba7b555e7d9f4461b285cbe9687888f3c4a79ed9f1
4
- data.tar.gz: 88585a241ac13801752029b6c1d28eabd3fded78b711a4c749602d51e0286900
3
+ metadata.gz: ed033686b019c19af40c4b01ac6d465c8df15cc9b26b185927341d59d9eb1e8f
4
+ data.tar.gz: 934ad51b7ef148eee7fcace86be3aa4888662d47b88221bd31c7fe8e82e2d6a0
5
5
  SHA512:
6
- metadata.gz: db96992d3c93a7b446613954d26fb36c1488eabbd9d47cead53950a3751053e05d473f495a23360cc34b580edb53f6c401c57492b7ad59e93fed4fab37155472
7
- data.tar.gz: '0843c1e25291a8b97bab9bb61f7415f708cfa0b82e2cd93933fe0aeee9133c740d2c740821c20eca3b27182c44047aff843c02e108020805ce90489b78d70470'
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 = " #{time_ago_in_words(pb_date_time.convert_to_timestamp)} ago"
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "14.2.1"
5
- VERSION = "14.3.0.pre.rc.2"
5
+ VERSION = "14.3.0.pre.rc.4"
6
6
  end
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.2
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-05 00:00:00.000000000 Z
12
+ date: 2024-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack