l43_time 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/l43/time/tools/format_ts.rb +13 -16
- data/lib/l43/time/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bada7ae04b6b801708365b0538c92057a380c8c75982b9f4bd09582e2a1e53d5
|
|
4
|
+
data.tar.gz: 0b7308732b154084de0e2ffd4cd3a4b70853e501aace43481d598d0f8dcbf78c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f64ac006a10b5836ee7d3a16b9c40e04b11635d82ae3a882e053d7c58e04e34890edda29632265afc0358ca73ea6b45e974de1a04da2efa58931ce5ca3bdba82
|
|
7
|
+
data.tar.gz: 6d74b612cb85ecc8a5f8cb160f9510eed7284504aeea51ff6d1f53e979be4df05b546cd9d1b7c56c82d20503ba6b12450dbfd5dd94e44b4e8dbc622d61f22916
|
|
@@ -22,10 +22,9 @@ module L43
|
|
|
22
22
|
|
|
23
23
|
def format_ts(ts, **opts)
|
|
24
24
|
options = Options.new(timestamp: ts, **opts)
|
|
25
|
-
ts
|
|
26
|
-
case split_parts(ts, options:)
|
|
25
|
+
case split_parts(ts, options)
|
|
27
26
|
in :ok, parts
|
|
28
|
-
format_parts(parts, options
|
|
27
|
+
format_parts(parts, options)
|
|
29
28
|
in error
|
|
30
29
|
error
|
|
31
30
|
end
|
|
@@ -48,25 +47,25 @@ module L43
|
|
|
48
47
|
[hs, "hours"], [ms, "minutes"], [secs, "seconds"], [frac, "second's decimal part"]]
|
|
49
48
|
.map do |value, name|
|
|
50
49
|
culprit = name
|
|
51
|
-
Integer(value)
|
|
50
|
+
Integer(value.to_s.gsub(/^0*(?=\d)/, ''))
|
|
52
51
|
end
|
|
53
52
|
check_range(*int_values, options:)
|
|
54
53
|
rescue ArgumentError => ae
|
|
55
54
|
if ae.message.start_with?("invalid value for Integer():")
|
|
56
|
-
return
|
|
55
|
+
return Result.error("invalid integer in #{culprit} in timestamp: #{options.timestamp.inspect}")
|
|
57
56
|
end
|
|
58
57
|
raise
|
|
59
58
|
end
|
|
60
59
|
|
|
61
60
|
MAX_ALLOWED_FOR_M_OR_S = 59
|
|
62
61
|
def check_range(hs, ms, secs, frac, options:)
|
|
63
|
-
return
|
|
64
|
-
return
|
|
62
|
+
return Result.error("minutes > #{MAX_ALLOWED_FOR_M_OR_S} in timestamp: #{options.timestamp.inspect}") if ms > MAX_ALLOWED_FOR_M_OR_S
|
|
63
|
+
return Result.error("seconds > #{MAX_ALLOWED_FOR_M_OR_S} in timestamp: #{options.timestamp.inspect}") if secs > MAX_ALLOWED_FOR_M_OR_S
|
|
65
64
|
|
|
66
65
|
Result.ok([hs, ms, secs, frac])
|
|
67
66
|
end
|
|
68
67
|
|
|
69
|
-
def convert_and_decimals(parts, options
|
|
68
|
+
def convert_and_decimals(parts, options)
|
|
70
69
|
parts => *hms, secs
|
|
71
70
|
case secs.split(options.dec_seps)
|
|
72
71
|
in [_]
|
|
@@ -74,13 +73,11 @@ module L43
|
|
|
74
73
|
in [s, frac]
|
|
75
74
|
check_parts(*hms, s, frac, options)
|
|
76
75
|
else
|
|
77
|
-
|
|
76
|
+
Result.error("too many decimal points in seconds part of timestamp: #{secs.inspect}")
|
|
78
77
|
end
|
|
79
78
|
end
|
|
80
79
|
|
|
81
|
-
def
|
|
82
|
-
|
|
83
|
-
def format_parts(parts, options:)
|
|
80
|
+
def format_parts(parts, options)
|
|
84
81
|
parts =
|
|
85
82
|
parts.drop_while(&:zero?) if options.suppress_leading_zeroes
|
|
86
83
|
parts => *parts, frac
|
|
@@ -91,8 +88,8 @@ module L43
|
|
|
91
88
|
Result.ok([*parts, seconds].join(options.joiner))
|
|
92
89
|
end
|
|
93
90
|
|
|
94
|
-
def split_parts(ts, options
|
|
95
|
-
return
|
|
91
|
+
def split_parts(ts, options)
|
|
92
|
+
return Result.error("empty timestamp") if ts.empty?
|
|
96
93
|
|
|
97
94
|
parts =
|
|
98
95
|
case ts.split(options.seps)
|
|
@@ -103,10 +100,10 @@ module L43
|
|
|
103
100
|
in [_, _, _] => tripple
|
|
104
101
|
tripple
|
|
105
102
|
else
|
|
106
|
-
return
|
|
103
|
+
return Result.error("too many parts in timestamp: #{ts.inspect}")
|
|
107
104
|
end
|
|
108
105
|
|
|
109
|
-
convert_and_decimals(parts, options
|
|
106
|
+
convert_and_decimals(parts, options)
|
|
110
107
|
end
|
|
111
108
|
|
|
112
109
|
end
|
data/lib/l43/time/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: l43_time
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Dober
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-08-
|
|
10
|
+
date: 2026-08-17 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: ostruct
|
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 4.0.
|
|
103
|
+
version: 4.0.2
|
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
|
106
106
|
- - ">="
|