iers 0.3.0 → 0.3.1

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: 39a64a5333955d6d28a26abc77c01371004f91b8fb8ca4b958f3ac5d415cca13
4
- data.tar.gz: 1f219ef6f35bc93ab6263832546a3af6534a7d2a29007425cfa54b2abea6c284
3
+ metadata.gz: 1d3826650e5fd3bcabe029c7a531bd3abd53213b06df36135c254875b8d81db9
4
+ data.tar.gz: b3f444b9b216fefa81776e8ea8d11fd872ce153baea1ae780055c66d0431be64
5
5
  SHA512:
6
- metadata.gz: cd2df5b1019640ac16f44d7289a5af2721fc90bef064785921701992fd6798c96c94ce9ef9f34f69323e79baba9b4d2ab28310520045b18c7ac1332d63fc6b69
7
- data.tar.gz: 42cc738efcb811f3f01f2de2d303d89b333a33ae394cbacc27f261cda39ab00e8e982ff2e3706eaac93b40a25a0e2522cfeb3d2dfe78c196137f7e3fbb8fd7b0
6
+ metadata.gz: db698e6202ba685d7a3c0552c97f2dbe0cce5a76e572c985937a52e824b8375b7d6adc4a823a5e7e10ca73f4d4cfc7ec3d3d5a1639ff8af20d88ddf168180a71
7
+ data.tar.gz: e2646d5321100190836f0c8bbd2978a4a352ece96250b549e4dfe351217b7478dbdac9fa98cba51996099b456b4ef46524ac8daca0360b9dd9c9bc3785c23318
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 - 2026-09-13
4
+
5
+ ### Fixed
6
+
7
+ - Reading a date too large or too small for a Float no longer writes to the
8
+ caller's stderr. `Kernel#Float` warns "Integer out of Float range" for such
9
+ a magnitude, and for a Rational whose numerator or denominator has one, so a
10
+ query far outside the data announced itself before being refused. An Integer
11
+ or a Rational is measured and converted directly now, which is quiet, while
12
+ everything else still goes through `Kernel#Float`, which is what refuses a
13
+ String or a Symbol. The values are unchanged: a magnitude past the range of
14
+ a Float was an Infinity before and is one now.
15
+
3
16
  ## 0.3.0 - 2026-09-06
4
17
 
5
18
  ### Fixed
@@ -28,9 +28,9 @@ module IERS
28
28
  # @raise [ArgumentError] if no valid input is provided
29
29
  def to_mjd(input = nil, jd: nil, mjd: nil)
30
30
  if mjd
31
- Float(mjd)
31
+ to_float(mjd)
32
32
  elsif jd
33
- Float(jd) - JD_MJD_OFFSET
33
+ to_float(jd) - JD_MJD_OFFSET
34
34
  elsif input.is_a?(Time)
35
35
  input.to_datetime.ajd.to_f - JD_MJD_OFFSET
36
36
  elsif input.is_a?(Date)
@@ -41,5 +41,31 @@ module IERS
41
41
  "got #{input.inspect}"
42
42
  end
43
43
  end
44
+
45
+ # A date as a Float, without writing to the caller's stderr on the way.
46
+ #
47
+ # +Kernel#Float+ warns "Integer out of Float range" for a magnitude that
48
+ # does not fit one, and for a Rational whose numerator or denominator does
49
+ # not either, so a date far outside the data announced itself before being
50
+ # refused. An Integer or a Rational is measured first and converted
51
+ # directly, which is quiet; everything else still goes through
52
+ # +Kernel#Float+, which is what refuses a String or a nil.
53
+ #
54
+ # The value is unchanged: a magnitude past the range of a Float was an
55
+ # Infinity before and is one now.
56
+ #
57
+ # @param value [Numeric, String] the date to read
58
+ # @return [Float]
59
+ # @raise [ArgumentError, TypeError] if it is not a number
60
+ def to_float(value)
61
+ case value
62
+ when Float then value
63
+ when Integer, Rational
64
+ return value.to_f unless value.abs > Float::MAX
65
+
66
+ value.negative? ? -Float::INFINITY : Float::INFINITY
67
+ else Float(value)
68
+ end
69
+ end
44
70
  end
45
71
  end
data/lib/iers/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IERS
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémy Hannequin