bullet_train 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/account/dates_helper.rb +43 -6
- data/lib/bullet_train/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e8839a83798a6b0f6cb390b45cf7b32b2d332b23474472d296d4d5d56182074
|
4
|
+
data.tar.gz: 5a37fae85e7079df274dc18d398dcdbedc4a8e1c316dfd701b2fec8e4f7ec844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2f84890b0ec4c6cb993f0dc08e0487ed48b787761a9e5130a6f9d8203e4e6e86459a4f06f2aa19bcf28813b5ec7efbe3f7366decda3334eccd6e09b25092532
|
7
|
+
data.tar.gz: c67cd314e9e323b09523b2babb42fdd0068de0544e6ac84fde651d89e8db7a678de33f58f88d0e23467972c1d768fad5bb9a7435b967f46dc3b8961d19ab12a4
|
@@ -1,17 +1,54 @@
|
|
1
1
|
module Account::DatesHelper
|
2
|
-
def display_date(timestamp, format: :default, date_format: nil)
|
2
|
+
def display_date(timestamp, custom_date_format = nil, format: :default, date_format: nil)
|
3
|
+
return nil unless timestamp
|
3
4
|
format = date_format if date_format
|
4
|
-
|
5
|
+
|
6
|
+
if format && format == :default
|
7
|
+
# e.g. October 11, 2018
|
8
|
+
if custom_date_format
|
9
|
+
local_time(timestamp).strftime(custom_date_format)
|
10
|
+
elsif local_time(timestamp).year == local_time(Time.now).year
|
11
|
+
local_time(timestamp).strftime("%B %-d")
|
12
|
+
else
|
13
|
+
local_time(timestamp).strftime("%B %-d, %Y")
|
14
|
+
end
|
15
|
+
else
|
16
|
+
localize(local_time(timestamp).to_date, format: format)
|
17
|
+
end
|
5
18
|
end
|
6
19
|
|
7
|
-
def display_time(timestamp, format: :default, time_format: nil)
|
20
|
+
def display_time(timestamp, custom_time_format = nil, format: :default, time_format: nil)
|
21
|
+
return nil unless timestamp
|
8
22
|
format = time_format if time_format
|
9
|
-
|
23
|
+
|
24
|
+
if format && format == :default
|
25
|
+
# e.g. 4:22 PM
|
26
|
+
local_time(timestamp).strftime(custom_time_format || "%l:%M %p")
|
27
|
+
else
|
28
|
+
localize(local_time(timestamp).to_time, format: format)
|
29
|
+
end
|
10
30
|
end
|
11
31
|
|
12
|
-
def display_date_and_time(timestamp, format: :default, date_format: nil, time_format: nil)
|
32
|
+
def display_date_and_time(timestamp, custom_date_format = nil, custom_time_format = nil, format: :default, date_format: nil, time_format: nil)
|
33
|
+
return nil unless timestamp
|
13
34
|
format = "#{date_format} #{time_format}" if date_format && time_format
|
14
|
-
|
35
|
+
|
36
|
+
if format && format == :default
|
37
|
+
# e.g. Today at 4:22 PM
|
38
|
+
# e.g. Yesterday at 2:12 PM
|
39
|
+
# e.g. April 24 at 7:39 AM
|
40
|
+
# today?
|
41
|
+
if local_time(timestamp).to_date == local_time(Time.now).to_date
|
42
|
+
"Today at #{display_time(timestamp, custom_time_format)}"
|
43
|
+
# yesterday?
|
44
|
+
elsif (local_time(timestamp).to_date) == (local_time(Time.now).to_date - 1.day)
|
45
|
+
"Yesterday at #{display_time(timestamp, custom_time_format)}"
|
46
|
+
else
|
47
|
+
"#{display_date(timestamp, custom_date_format)} at #{display_time(timestamp, custom_time_format)}"
|
48
|
+
end
|
49
|
+
else
|
50
|
+
localize(local_time(timestamp).to_datetime, format: format)
|
51
|
+
end
|
15
52
|
end
|
16
53
|
|
17
54
|
def local_time(timestamp)
|
data/lib/bullet_train/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -753,8 +753,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
753
753
|
- !ruby/object:Gem::Version
|
754
754
|
version: '0'
|
755
755
|
requirements: []
|
756
|
-
rubygems_version: 3.
|
757
|
-
signing_key:
|
756
|
+
rubygems_version: 3.4.10
|
757
|
+
signing_key:
|
758
758
|
specification_version: 4
|
759
759
|
summary: Bullet Train
|
760
760
|
test_files: []
|