sixarm_ruby_time_terse 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/sixarm_ruby_time_terse/time.rb +73 -14
- data/test/sixarm_ruby_time_terse_test/time_test.rb +111 -8
- metadata +20 -21
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00c3a42bb2ef890edb7c5602e1427258cb4f52771456ddeada14b49fc72adc41
|
4
|
+
data.tar.gz: 2cce8a30bf91de3b897f52444a901fb783ed2f5806a7076c36ae5373f4e3859d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8d7160ab7a2e746e9644464d106df358d759368f26a63531eae48fcf0d7d142ad4ea49e548cec7ae63645864324ddc2c3090b79c0d6e99d19272f26a9cc8680
|
7
|
+
data.tar.gz: 634c7d22ed08067ff8f7aee723ed0851cdb8db0c6fb4932260f00b951fa931a5226ee0b202f684dcea3bf1b55c947166a18be22dd9c36ed63c7d57ad0c450382
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -4,35 +4,94 @@ Time class extensions.
|
|
4
4
|
=end
|
5
5
|
|
6
6
|
class Time
|
7
|
+
|
8
|
+
# Create a time terse string using the default format "YYYYMMDDTHHMMSSNNNNNNNNN"
|
9
|
+
#
|
10
|
+
# This standard format is specified in IETF RFC 3339 and ISO 8601.
|
11
|
+
#
|
12
|
+
# @see http://www.ietf.org/rfc/rfc3339.txt
|
13
|
+
#
|
14
|
+
# Example:
|
15
|
+
#
|
16
|
+
# time = Time.now
|
17
|
+
# time.terse
|
18
|
+
# => "20201231125959000000000"
|
19
|
+
#
|
20
|
+
# Return: [String] a time terse string
|
21
|
+
#
|
22
|
+
def terse(format = terse_format)
|
23
|
+
getutc.strftime(format)
|
24
|
+
end
|
7
25
|
|
8
|
-
#
|
26
|
+
# Shorthand for Time.now.terse
|
9
27
|
#
|
10
28
|
# Example:
|
11
29
|
#
|
12
|
-
# Time.
|
13
|
-
# => "
|
30
|
+
# Time.terse
|
31
|
+
# => "20201231125959000000000"
|
32
|
+
#
|
33
|
+
# Return: [String] Time.now time terse string
|
14
34
|
#
|
15
|
-
|
35
|
+
def self.terse(format = self.terse_format)
|
36
|
+
now.terse(format)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get terse format string
|
40
|
+
#
|
41
|
+
# Example:
|
16
42
|
#
|
17
|
-
#
|
43
|
+
# time.terse_format => "%Y%m%d%H%M%S%N"
|
18
44
|
#
|
19
|
-
|
20
|
-
|
45
|
+
# Return: [String] terse format string
|
46
|
+
#
|
47
|
+
def terse_format
|
48
|
+
@terse_format ||= '%Y%m%d%H%M%S%N'
|
21
49
|
end
|
22
50
|
|
23
|
-
#
|
51
|
+
# Set terse format string
|
24
52
|
#
|
25
53
|
# Example:
|
26
54
|
#
|
27
|
-
#
|
28
|
-
#
|
55
|
+
# time.terse_format = "%Y%m%d%H%M%S%N"
|
56
|
+
#
|
57
|
+
def terse_format=(format)
|
58
|
+
@terse_format = format
|
59
|
+
end
|
60
|
+
|
61
|
+
# Get class-scope terse format string
|
62
|
+
#
|
63
|
+
# Example:
|
64
|
+
#
|
65
|
+
# Time.terse_format => "%Y%m%d%H%M%S%N"
|
66
|
+
#
|
67
|
+
# Return: [String] terse format string
|
68
|
+
#
|
69
|
+
def self.terse_format
|
70
|
+
@@terse_format ||= '%Y%m%d%H%M%S%N'
|
71
|
+
end
|
72
|
+
|
73
|
+
# Set class-scope terse format string
|
74
|
+
#
|
75
|
+
# Example:
|
76
|
+
#
|
77
|
+
# Time.terse_format = "%Y%m%d%H%M%S%N"
|
78
|
+
#
|
79
|
+
# Return: [String] terse format string
|
80
|
+
#
|
81
|
+
def self.terse_format=(format)
|
82
|
+
@@terse_format = format
|
83
|
+
end
|
84
|
+
|
85
|
+
# Get class-scope terse format default string
|
86
|
+
#
|
87
|
+
# Example:
|
29
88
|
#
|
30
|
-
#
|
89
|
+
# Time.terse_format_default => "%Y%m%d%H%M%S%N"
|
31
90
|
#
|
32
|
-
#
|
91
|
+
# Return: [String] terse format default string
|
33
92
|
#
|
34
|
-
def self.
|
35
|
-
|
93
|
+
def self.terse_format_default
|
94
|
+
"%Y%m%d%H%M%S%N"
|
36
95
|
end
|
37
96
|
|
38
97
|
end
|
@@ -3,16 +3,119 @@ require "sixarm_ruby_time_terse_test"
|
|
3
3
|
|
4
4
|
describe Time do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
TERSE_FORMAT_MISSING = nil
|
7
|
+
TERSE_FORMAT_DEFAULT = "%Y%m%d%H%M%S%N"
|
8
|
+
TERSE_FORMAT_CUSTOM = "~%Y~%m~%d~%H~%M~%S~%N~"
|
9
|
+
|
10
|
+
describe "*terse" do
|
11
|
+
|
12
|
+
describe "#terse" do
|
13
|
+
before do
|
14
|
+
@time = Time.now
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "with default format" do
|
18
|
+
before do
|
19
|
+
@time.terse_format = TERSE_FORMAT_MISSING
|
20
|
+
end
|
21
|
+
it "return terse" do
|
22
|
+
actual = @time.terse
|
23
|
+
expect(actual).must_match(/^\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d$/)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "with custom format" do
|
28
|
+
before do
|
29
|
+
@time.terse_format = TERSE_FORMAT_CUSTOM
|
30
|
+
end
|
31
|
+
it "return terse" do
|
32
|
+
actual = @time.terse
|
33
|
+
expect(actual).must_match(/^~\d\d\d\d~\d\d~\d\d~\d\d~\d\d~\d\d~\d\d\d\d\d\d\d\d\d~$/)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe ".terse" do
|
40
|
+
|
41
|
+
describe "with default format" do
|
42
|
+
before do
|
43
|
+
Time.terse_format = TERSE_FORMAT_MISSING
|
44
|
+
end
|
45
|
+
it "return terse" do
|
46
|
+
actual = Time.terse
|
47
|
+
expect(actual).must_match(/^\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d$/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "with custom format" do
|
52
|
+
before do
|
53
|
+
Time.terse_format = TERSE_FORMAT_CUSTOM
|
54
|
+
end
|
55
|
+
it "return terse" do
|
56
|
+
actual = Time.terse
|
57
|
+
expect(actual).must_match(/^~\d\d\d\d~\d\d~\d\d~\d\d~\d\d~\d\d~\d\d\d\d\d\d\d\d\d~$/)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "*terse_format" do
|
66
|
+
|
67
|
+
describe "#terse_format" do
|
68
|
+
|
69
|
+
before do
|
70
|
+
@time = Time.now
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "with default format" do
|
74
|
+
before do
|
75
|
+
@time.terse_format = TERSE_FORMAT_MISSING
|
76
|
+
end
|
77
|
+
it "return default value" do
|
78
|
+
actual = @time.terse_format
|
79
|
+
expect(actual).must_equal(TERSE_FORMAT_DEFAULT)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "with custom format" do
|
84
|
+
before do
|
85
|
+
@time.terse_format = TERSE_FORMAT_CUSTOM
|
86
|
+
end
|
87
|
+
it "return custom value" do
|
88
|
+
actual = @time.terse_format
|
89
|
+
expect(actual).must_equal(TERSE_FORMAT_CUSTOM)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
10
93
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
94
|
+
|
95
|
+
describe ".terse_format" do
|
96
|
+
|
97
|
+
describe "with default value" do
|
98
|
+
before do
|
99
|
+
Time.terse_format = TERSE_FORMAT_MISSING
|
100
|
+
end
|
101
|
+
it "return default value" do
|
102
|
+
actual = Time.terse_format
|
103
|
+
expect(actual).must_equal(TERSE_FORMAT_DEFAULT)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "with custom value" do
|
108
|
+
before do
|
109
|
+
Time.terse_format = TERSE_FORMAT_CUSTOM
|
110
|
+
end
|
111
|
+
it "return custom value" do
|
112
|
+
actual = Time.terse_format
|
113
|
+
expect(actual).must_equal(TERSE_FORMAT_CUSTOM)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
14
117
|
end
|
15
|
-
|
118
|
+
|
16
119
|
end
|
17
120
|
|
18
121
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sixarm_ruby_time_terse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SixArm
|
@@ -39,7 +39,7 @@ cert_chain:
|
|
39
39
|
tzpk/VnZXj7Ek/earx+N/Z+Wtnl2xENm5IF8SFPeI1HFa9NH47pqtxF1YKpNIEVc
|
40
40
|
2xa2BNHSePe7tys/2hbmZuyMu8X5ERmovsabSXB3a+YwtJh5c2jhA21wF7986s0q
|
41
41
|
-----END CERTIFICATE-----
|
42
|
-
date:
|
42
|
+
date: 2019-04-06 00:00:00.000000000 Z
|
43
43
|
dependencies:
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: minitest
|
@@ -47,7 +47,7 @@ dependencies:
|
|
47
47
|
requirements:
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 5.11.
|
50
|
+
version: 5.11.1
|
51
51
|
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '6'
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 5.11.
|
60
|
+
version: 5.11.1
|
61
61
|
- - "<"
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '6'
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 12.3.
|
90
|
+
version: 12.3.0
|
91
91
|
- - "<"
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '13'
|
@@ -97,7 +97,7 @@ dependencies:
|
|
97
97
|
requirements:
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: 12.3.
|
100
|
+
version: 12.3.0
|
101
101
|
- - "<"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '13'
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.14.1
|
111
111
|
- - "<"
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '2'
|
@@ -117,7 +117,7 @@ dependencies:
|
|
117
117
|
requirements:
|
118
118
|
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 0.
|
120
|
+
version: 0.14.1
|
121
121
|
- - "<"
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '2'
|
@@ -127,7 +127,7 @@ dependencies:
|
|
127
127
|
requirements:
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 4.6.
|
130
|
+
version: 4.6.1
|
131
131
|
- - "<"
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '5'
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
requirements:
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: 4.6.
|
140
|
+
version: 4.6.1
|
141
141
|
- - "<"
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '5'
|
@@ -147,7 +147,7 @@ dependencies:
|
|
147
147
|
requirements:
|
148
148
|
- - ">="
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: 2.
|
150
|
+
version: 2.10.0
|
151
151
|
- - "<"
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '3'
|
@@ -157,7 +157,7 @@ dependencies:
|
|
157
157
|
requirements:
|
158
158
|
- - ">="
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
version: 2.
|
160
|
+
version: 2.10.0
|
161
161
|
- - "<"
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '3'
|
@@ -167,7 +167,7 @@ dependencies:
|
|
167
167
|
requirements:
|
168
168
|
- - ">="
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version: 4.
|
170
|
+
version: 4.7.3
|
171
171
|
- - "<"
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '5'
|
@@ -177,7 +177,7 @@ dependencies:
|
|
177
177
|
requirements:
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 4.
|
180
|
+
version: 4.7.3
|
181
181
|
- - "<"
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '5'
|
@@ -187,7 +187,7 @@ dependencies:
|
|
187
187
|
requirements:
|
188
188
|
- - ">="
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version: 3.
|
190
|
+
version: 3.3.0
|
191
191
|
- - "<"
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '4'
|
@@ -197,7 +197,7 @@ dependencies:
|
|
197
197
|
requirements:
|
198
198
|
- - ">="
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: 3.
|
200
|
+
version: 3.3.0
|
201
201
|
- - "<"
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '4'
|
@@ -207,7 +207,7 @@ dependencies:
|
|
207
207
|
requirements:
|
208
208
|
- - ">="
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version: 0.
|
210
|
+
version: 0.52.1
|
211
211
|
- - "<"
|
212
212
|
- !ruby/object:Gem::Version
|
213
213
|
version: '1'
|
@@ -217,11 +217,11 @@ dependencies:
|
|
217
217
|
requirements:
|
218
218
|
- - ">="
|
219
219
|
- !ruby/object:Gem::Version
|
220
|
-
version: 0.
|
220
|
+
version: 0.52.1
|
221
221
|
- - "<"
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '1'
|
224
|
-
description: Time.terse
|
224
|
+
description: Time.terse methods to generate a string formatted with YMDHMSN
|
225
225
|
email: sixarm@sixarm.com
|
226
226
|
executables: []
|
227
227
|
extensions: []
|
@@ -256,8 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
256
|
- !ruby/object:Gem::Version
|
257
257
|
version: '0'
|
258
258
|
requirements: []
|
259
|
-
|
260
|
-
rubygems_version: 2.7.7
|
259
|
+
rubygems_version: 3.0.3
|
261
260
|
signing_key:
|
262
261
|
specification_version: 4
|
263
262
|
summary: SixArm.com → Ruby → Time.terse method
|
metadata.gz.sig
CHANGED
Binary file
|