astrolith 0.2.2 → 0.2.3

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: 519ed7ad086a977ac2249b240abb1c2e2ec58a7ab63830da9da910c006089e1f
4
- data.tar.gz: 2b3f902700a84d5e2c63e387d974e2676c651947e5200cc335a83bf9421db9d5
3
+ metadata.gz: 9de2dad823a451800d3b28a127f4a62bd201064ae5f71c691b311f54565e7f58
4
+ data.tar.gz: 823302415f7d0181769cef6e5e2e2861b683ab3178c587b9adda0d3d6080bb16
5
5
  SHA512:
6
- metadata.gz: eae65858ba4558919828635869533e47702c4896ff95dd7fe8d46f0acdd16083b61d27eb111d6b14a3dce0f2d5f9aa6f75ffb942b8a5837af087d13f605e14b3
7
- data.tar.gz: 97554724c34cd8109d1ac86e978a490de75c822d6aeeb03f39a61c0734362806f847e1440c97f37231c4fc3f6e4d8221d2daa814fa36fc7b6caeef63591abb9f
6
+ metadata.gz: 20bf05ae4bddb520d581d14fe6c6bba050c09fa24aa1e63e754434770256702e14888e1d575a21e97a79a77e9f81efa67f184dfa3bed83c1bb0c2998b867a2e2
7
+ data.tar.gz: 47d8e9b4e5b80ce48f29aa508be87a1d5ffe8009d788301f1d482b38eb1f821c35859c315f25cd151f4f778de86f08702de4d347f5154308f73b65c0fefe30be
@@ -22,7 +22,8 @@ module Astrolith
22
22
  # Convert to Julian Day Number for Swiss Ephemeris
23
23
  def to_julian_day(timezone_offset = 0)
24
24
  # Adjust for timezone offset (in hours)
25
- adjusted_time = @datetime - (timezone_offset * 3600)
25
+ # Convert hours to days for DateTime arithmetic (DateTime - number treats number as days)
26
+ adjusted_time = @datetime - Rational(timezone_offset, 24)
26
27
 
27
28
  # Use Swiss Ephemeris to calculate Julian Day
28
29
  # swe_julday takes 4 arguments: year, month, day, hour (as decimal)
@@ -65,7 +65,24 @@ module Astrolith
65
65
  return @offset if @offset
66
66
 
67
67
  if @timezone.is_a?(TZInfo::Timezone) && @datetime
68
- period = @timezone.period_for_local(@datetime)
68
+ # Use periods_for_local to handle DST transitions
69
+ periods = @timezone.periods_for_local(@datetime)
70
+
71
+ if periods.empty?
72
+ # Invalid local time (spring forward) - the time doesn't exist
73
+ # Use the period after the transition
74
+ period = @timezone.period_for_utc(@datetime.to_time.utc)
75
+ elsif periods.size == 1
76
+ # Normal case - unambiguous local time
77
+ period = periods.first
78
+ else
79
+ # Ambiguous local time (fall back) - the time occurs twice
80
+ # Choose the first period (DST/summer time) by default
81
+ # This matches common expectations: if someone says "1:30 AM" on a fall-back day,
82
+ # they likely mean the first occurrence (before clocks fall back)
83
+ period = periods.first
84
+ end
85
+
69
86
  period.utc_total_offset
70
87
  else
71
88
  0
@@ -1,3 +1,3 @@
1
1
  module Astrolith
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: astrolith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Go-pye
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-05 00:00:00.000000000 Z
11
+ date: 2026-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: swe4r