Module: When::Ephemeris::ChineseTrueLunation::MethodS

Includes:
JujiMethods
Defined in:
lib/when_exe/region/chinese.rb

Overview

授時暦の平均太陽の計算

Instance Method Summary collapse

Methods included from JujiMethods

#_perihelion_, #_winter_solstice_, #_year_length_

Instance Method Details

#cn_to_time_(cn, time0 = nil) ⇒ Numeric

周期番号 -> 日時(平気)

Parameters:

  • cn (Numeric)

    周期番号

  • time0 (Numeric) (defaults to: nil)

    日時の初期近似値(ダミー)

Returns:



523
524
525
526
# File 'lib/when_exe/region/chinese.rb', line 523

def cn_to_time_(cn, time0=nil)
  year, mean_term = (cn / 12.0 - @longitude_shift - @year_epoch).divmod(1)
  @day_epoch + _winter_solstice(year) + _year_length_(year) * mean_term
end

#time_to_cn(t, cn0 = nil) ⇒ Numeric

日時 -> 周期番号

Parameters:

Returns:



511
512
513
514
# File 'lib/when_exe/region/chinese.rb', line 511

def time_to_cn(t, cn0=nil)
  cn0 ||= (t.to_f - @day_epoch) / @year_length + @year_epoch + @longitude_shift
  root(cn0 * 12, t.to_f) {|cn| cn_to_time(cn) }
end