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_F =
{'M'=>'_co:Indian::CentralIndia', 'SS'=>'_co:Indian::Ujjain', 'SB'=>'_co:Indian::Ujjain'}
Location_E =
{'B'=>'_co:Indian::Dacca', 'BZ'=>'_co:Indian::Dacca', 'H'=>'_co:Iranian::Tehran', 'HZ'=>'_co:Iranian::Tehran'}
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, 'B'=> 593, 'BZ'=>594, 'H'=> 621, 'HZ'=> 622}
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 Lunar

Lunar::Pattern

Constants inherited from TM::Calendar

TM::Calendar::HashProperty

Constants included from When::Coordinates

When::Coordinates::Bahai, When::Coordinates::Chinese, When::Coordinates::Common, When::Coordinates::DefaultDateIndices, When::Coordinates::DefaultDayIndex, When::Coordinates::DefaultTimeIndices, When::Coordinates::Indian, When::Coordinates::Iranian, 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::Russian, When::Coordinates::Tibetan, When::Coordinates::VALUE, When::Coordinates::Yi

Constants included from Parts::Resource

Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIDecode, Parts::Resource::IRIDecodeTable, Parts::Resource::IRIEncode, Parts::Resource::IRIEncodeTable, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty

Instance Attribute Summary

Attributes inherited from EphemerisBasedLuniSolar

#formula

Attributes inherited from EphemerisBased

#formula

Attributes inherited from TM::Calendar

#diff_to_CE, #epoch_in_CE, #reference_frame, #time_basis

Attributes included from TimeStandard::TimeBasis

#_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 included from Lunar

#_verify, #lunar_table, #verify

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, #strftime, #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_deg_225, to_dms

Methods inherited from TM::ReferenceSystem

#domain, #name

Methods included from Parts::Resource

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

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:



756
757
758
759
760
761
762
763
764
# File 'lib/when_exe/region/indian.rb', line 756

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

月初の通日

Parameters:

  • m (Integer)

    通月

Returns:

  • (Integer)

    月初の通日



705
706
707
708
709
710
# File 'lib/when_exe/region/indian.rb', line 705

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

年初の通月

Parameters:

  • y (Integer)

Returns:

  • (Integer)

    年初の通月



718
719
720
# File 'lib/when_exe/region/indian.rb', line 718

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))

Returns:

  • (Array<Numeric>)

    ( y, m, d )

    y - 年(Integer)
    m - 月(When::Coordinates::Pair)
    d - 日(Integer)


731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/when_exe/region/indian.rb', line 731

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