Module: Sekki24
- Defined in:
- lib/sekki24.rb,
lib/sekki24.rb,
lib/sekki24/kou.rb,
lib/sekki24/term.rb,
lib/sekki24/names.rb,
lib/sekki24/solar.rb,
lib/sekki24/finder.rb,
lib/sekki24/delta_t.rb,
lib/sekki24/version.rb,
lib/sekki24/nutation.rb,
lib/sekki24/zassetsu.rb,
lib/sekki24/kou_names.rb,
lib/sekki24/lunar/moon.rb,
lib/sekki24/solar/fast.rb,
lib/sekki24/time_scale.rb,
lib/sekki24/solar/precise.rb,
lib/sekki24/lunisolar/date.rb,
lib/sekki24/lunisolar/month.rb,
lib/sekki24/seventy_two_kou.rb,
lib/sekki24/zassetsu_calendar.rb,
lib/sekki24/lunar/phase_finder.rb,
lib/sekki24/lunisolar/calendar.rb,
lib/sekki24/solar/vsop87_earth.rb,
lib/sekki24/lunar/periodic_terms.rb,
lib/sekki24/lunisolar/month_builder.rb
Defined Under Namespace
Modules: DeltaT, Finder, KouNames, Lunar, Lunisolar, Names, Nutation, SeventyTwoKou, Solar, TimeScale, ZassetsuCalendar
Classes: Error, Kou, Term, Zassetsu
Constant Summary
collapse
- MIN_YEAR =
1900
- MAX_YEAR =
2100
- DEFAULT_TIMEZONE =
"+00:00"
- DEFAULT_PRECISION =
:precise
- VERSION =
"1.0.0"
Class Method Summary
collapse
-
.clear_cache! ⇒ Object
-
.current(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.current_kou(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.current_zassetsu(date = Date.today, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.gregorian(lunar_year, month, day, leap: false, tz: DEFAULT_TIMEZONE) ⇒ Object
-
.kou(year, ordinal, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.kou_year(year, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.lunisolar(value, tz: DEFAULT_TIMEZONE) ⇒ Object
-
.lunisolar_year(year, tz: DEFAULT_TIMEZONE) ⇒ Object
-
.moon_longitude(time) ⇒ Object
-
.new_moon_after(time = Time.now) ⇒ Object
-
.new_moon_before(time = Time.now) ⇒ Object
-
.new_moons(year, tz: DEFAULT_TIMEZONE) ⇒ Object
-
.next_kou(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.next_term(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.on(date, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.prev_kou(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.prev_term(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.term(year, key, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.year(year, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.zassetsu(year, key, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.zassetsu_on(date, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
-
.zassetsu_year(year, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
Class Method Details
.current(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
43
44
45
46
47
|
# File 'lib/sekki24.rb', line 43
def current(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION)
instant = ensure_time(time)
navigation_terms(instant, tz, precision).select { |entry| entry.time <= instant }.max ||
raise(RangeError, "no current solar term in the supported range")
end
|
.current_kou(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
.current_zassetsu(date = Date.today, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
.gregorian(lunar_year, month, day, leap: false, tz: DEFAULT_TIMEZONE) ⇒ Object
.kou(year, ordinal, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
.kou_year(year, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
.lunisolar(value, tz: DEFAULT_TIMEZONE) ⇒ Object
.lunisolar_year(year, tz: DEFAULT_TIMEZONE) ⇒ Object
.moon_longitude(time) ⇒ Object
.new_moon_after(time = Time.now) ⇒ Object
.new_moon_before(time = Time.now) ⇒ Object
.new_moons(year, tz: DEFAULT_TIMEZONE) ⇒ Object
.next_kou(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
.next_term(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
49
50
51
52
53
|
# File 'lib/sekki24.rb', line 49
def next_term(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION)
instant = ensure_time(time)
navigation_terms(instant, tz, precision).select { |entry| entry.time > instant }.min ||
raise(RangeError, "no next solar term in the supported range")
end
|
.on(date, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/sekki24.rb', line 61
def on(date, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION)
unless date.is_a?(Date)
raise TypeError, "expected Date, got #{date.class}"
end
year(date.year, tz: tz, precision: precision).find { |entry| entry.to_date == date }
end
|
.prev_kou(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
.prev_term(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
55
56
57
58
59
|
# File 'lib/sekki24.rb', line 55
def prev_term(time = Time.now, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION)
instant = ensure_time(time)
navigation_terms(instant, tz, precision).select { |entry| entry.time < instant }.max ||
raise(RangeError, "no previous solar term in the supported range")
end
|
.term(year, key, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
38
39
40
41
|
# File 'lib/sekki24.rb', line 38
def term(year, key, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION)
definition = Names.fetch(key)
self.year(year, tz: tz, precision: precision).find { |entry| entry.key == definition.key }
end
|
.year(year, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/sekki24.rb', line 27
def year(year, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION)
calendar_year = validate_year(year)
mode, solar = resolve_precision(precision)
cache_key = [calendar_year, TimeScale.timezone_key(tz), mode].freeze
cached = @cache_mutex.synchronize { @year_cache[cache_key] }
return cached if cached
calculated = calculate_year(calendar_year, tz, mode, solar)
@cache_mutex.synchronize { @year_cache[cache_key] ||= calculated }
end
|
.zassetsu(year, key, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
.zassetsu_on(date, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object
.zassetsu_year(year, tz: DEFAULT_TIMEZONE, precision: DEFAULT_PRECISION) ⇒ Object