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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33cf3abc40bf98414a1fadcd34df727e952d923237bca2bde6c44f232b298f62
4
- data.tar.gz: 13208a8c1e985c2e0e76194a1ab6b22c179e2b3131a82ae063e3f743cad2ae22
3
+ metadata.gz: bada7ae04b6b801708365b0538c92057a380c8c75982b9f4bd09582e2a1e53d5
4
+ data.tar.gz: 0b7308732b154084de0e2ffd4cd3a4b70853e501aace43481d598d0f8dcbf78c
5
5
  SHA512:
6
- metadata.gz: f085d3bcb22fc8415d49650097cd019ef88b64d9b29851d05e72c12e2bacc14a83bef1e4361ed98f2dab3a013aeeb69eed55d2bbda00a210ddfa643119e6d564
7
- data.tar.gz: 526039f9541fe5b52efdb5726a06643953483af20b98bcd0f76992ca8e11b462af36ef55d442090a95b6ed3ecf623a1c6b1c521f64c833e77ed5272b5b0c27b4
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 = ts.strip
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 error_result("invalid integer in #{culprit}", options:)
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 error_result("minutes > #{MAX_ALLOWED_FOR_M_OR_S}", options:) if ms > MAX_ALLOWED_FOR_M_OR_S
64
- return error_result("seconds > #{MAX_ALLOWED_FOR_M_OR_S}", options:) if secs > MAX_ALLOWED_FOR_M_OR_S
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
- error_result("too many decimal points in seconds part", options:)
76
+ Result.error("too many decimal points in seconds part of timestamp: #{secs.inspect}")
78
77
  end
79
78
  end
80
79
 
81
- def error_result(message, options:) = Result.error("#{message} in timestamp: #{options.timestamp.inspect}")
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 error_result("empty timestamp", options:) if ts.empty?
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 error_result("too many parts", options:)
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module L43
4
4
  module Time
5
- VERSION = '0.1.8'
5
+ VERSION = '0.1.9'
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: AGPL-3.0-or-later
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.8
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-14 00:00:00.000000000 Z
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.1
103
+ version: 4.0.2
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="