Class: When::CalendarTypes::HinduLuniSolar

Inherits:
EphemerisBasedLuniSolar show all
Defined in:
lib/when_exe/region/indian.rb

Overview

Hindu Luni-Solar Calendar

Direct Known Subclasses

BalineseLuniSolar

Constant Summary collapse

Formula =

Calendar Type

{'M'=>'Formula', 'SS'=>'Hindu?bija=SS', 'SB'=>'Hindu?bija=SB'}
Location =
{'M'=>'_co:IndianCities::CentralIndia', 'SS'=>'_co:IndianCities::Ujjain', 'SB'=>'_co:IndianCities::Ujjain'}
CycleOffset =
{'M'=>+23.25/30, 'SS'=>0.0, 'SB'=>0.0}
HinduStyle =
{'A'=>0, 'P'=>1, 'PX'=>2}
YearEpoch =
{'V'=>-58,'VZ'=>-57,'S'=>78, 'SZ'=>79}
LEAP_MAP =

[w]/b [n]/l #0 #1 #2

{[nil,  false] => [ 0,    0,    0  ],
[nil,  true ] => [-1.5, -1.5, -1.5],
[true, false] => [+0.5, -0.5, -2.5],
[true, true ] => [-1,   -2,   -1  ]}

Constants included from When::Coordinates

When::Coordinates::Bahai, When::Coordinates::CommonResidue, When::Coordinates::DefaultDateIndices, When::Coordinates::DefaultDayIndex, When::Coordinates::DefaultTimeIndices, When::Coordinates::IndianCities, When::Coordinates::Javanese, When::Coordinates::MATCH, When::Coordinates::Mayan, When::Coordinates::PERIOD, When::Coordinates::PERIOD_NAME, When::Coordinates::PRECISION, When::Coordinates::PRECISION_NAME, When::Coordinates::Tibetan, When::Coordinates::VALUE, When::Coordinates::Yi

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary

Attributes inherited from EphemerisBasedLuniSolar

#formula

Attributes inherited from EphemerisBased

#formula

Attributes inherited from TM::Calendar

#reference_frame, #time_basis

Attributes inherited from TM::ReferenceSystem

#domain_of_validity, #position

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Instance Method Summary collapse

Methods inherited from EphemerisBasedLuniSolar

#_coordinates_to_number, #_length, #_number_to_coordinates

Methods inherited from EphemerisBased

#_coordinates_to_number, #_length, #_number_to_coordinates, #_sum_

Methods inherited from TM::Calendar

_setup_, #_to_month_number_, #date_trans, #jul_trans, #rate_of_clock, #time_standard, #to_cal_date, #to_julian_date, #to_universal_time

Methods included from TimeStandard::TimeBasis

#_normalize_time_basis

Methods included from When::Coordinates

to_deg, to_dms

Methods inherited from TM::ReferenceSystem

#domain, #name

Methods included from Parts::Resource

#[], #^, _decode, _encode, _extract_prefix, _instance, _parse, _path_with_prefix, _replace_tags, _setup_, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?

Methods included from Parts::Resource::Pool

#[], #[]=, #_pool, #_setup_, #pool_keys

Methods included from Parts::Resource::Synchronize

#synchronize

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::Parts::Resource

Instance Method Details

#_ids_(date) ⇒ Array<When::Coordinates::Pair> #_ids_(date) ⇒ Array<When::Coordinates::Pair>

日時要素の翻訳表の取得

Overloads:



691
692
693
694
695
696
697
698
699
# File 'lib/when_exe/region/indian.rb', line 691

def _ids_(date)
  y, m = date
  y    = +y
  mm   = _new_year_month(y)
  return (_table(_new_month_(mm+m.to_i)) {|i| _new_month(mm+m+i/15.0)}) if m
  table = (0...26).to_a.map {|i| _tithi_to_coordinates((mm+i)*15)[1]}
  table.pop while table[-1].trunk < 11
  return table
end

#_new_month_(m) ⇒ Integer

月初の通日



640
641
642
643
644
645
# File 'lib/when_exe/region/indian.rb', line 640

def _new_month_(m)
  new_moon_time = @formula[-1].cn_to_time(m)
  new_moon_date = (new_moon_time + 0.5 + @formula[-1].long/360.0).floor
  sunrise_time = @formula[-1].sunrise(new_moon_date)
  (sunrise_time >= new_moon_time) ? new_moon_date : new_moon_date+1
end

#_new_year_month_(y) ⇒ Integer

年初の通月



653
654
655
# File 'lib/when_exe/region/indian.rb', line 653

def _new_year_month_(y)
  (Residue.mod(y-1) {|t| _tithi_to_coordinates(t*15)[0]})[0] + 1
end

#_tithi_to_coordinates(tithi) ⇒ Array<Numeric>

朔望日 -> 年・月・日

tithi : 朔望日(月の位相 / (CIRCLE/30))



666
667
668
669
670
671
672
673
674
675
676
677
678
# File 'lib/when_exe/region/indian.rb', line 666

def _tithi_to_coordinates(tithi)
  m, d = tithi.divmod(30)
  s    = [0,1,2].map {|i| (@formula[1].time_to_cn(30*(m+i)) - @cycle_offset).floor + 1 }
  f    = s[0]==s[1]
  if (d >= 15.0)
    d -=  15
    b  = true
    n  = true   unless @hindu_style==0
    f  = s[1]==s[2] if @hindu_style==1
  end
  y, m = (n ? s[1] : s[0]).divmod(12)
  return [y, Pair._force_pair(m+1, LEAP_MAP[[b,f]][@hindu_style]), d.floor]
end