Class: When::CalendarTypes::CalendarNote::JapaneseLuniSolarNote

Inherits:
When::CalendarTypes::CalendarNote show all
Defined in:
lib/when_exe/region/japanese_notes.rb

Overview

太陰太陽暦の暦注

Constant Summary collapse

StarMansions =

変換表 月日→27宿

[                                 #              正  2  3  4  5  6  7  8  9  10  11  12  
  [11, 13, 15, 17, 19, 21, 24,  0,  2,  4,  7,  9], # 0 : 本月本説 室12奎14胃16畢18參20鬼22張25角00氐02心04斗07虛10
  [ 5,  3,  1, 25, 23, 21, 19, 16, 14, 11,  8,  7], # 1 : 本月異説 尾05房03亢01翼26星24鬼22參20昴17婁15室12女09斗07
  [14, 16, 18, 20, 22, 24,  0,  3,  5,  7, 10, 12], # 2 : 閏月本説 婁15昴17觜19井21柳23張25角00房03尾05斗07危11壁13
  [12, 14, 16, 18, 19, 21, 24,  0,  2,  5,  8, 10], # 3 : 閏月異説 壁13婁15昴17觜19參20鬼22張25角00氐02尾05女09危11
  [14, 16, 18, 23, 22, 24,  0,  3,  5,  7,  8, 12]  # 4 : 閏月本説(元)        (星24)                      (女09)
]
StarMansionIndex =

変換表 27宿→28宿

(0..7).to_a + (9..27).to_a
WeekDepended =

七曜と27宿で決まる暦注

{
             # 日  月  火  水  木  金  土
  '甘露'   => [26, 17,  5, 22, 21,  3, 23],  # 軫27 畢18 尾05 柳23 鬼22 房03 星24
  '金剛峯' => [ 5,  8, 12, 16, 20, 24,  1],  # 尾05 女09 壁13 昴17 井21 張25 亢01
  '羅刹'   => [15, 21, 25, 19,  2, 13, 22]   # 胃16 鬼22 翼26 参20 氐02 奎14 柳23
}
Rokuyo =

六曜

When.Resource('_m:JapaneseTerms::六曜')

Constants inherited from When::CalendarTypes::CalendarNote

BahaiNotes, ChineseNotes, DefaultNotes, JavaneseNotes, JulianDayNotes, MayanNotes, YiNotes

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary

Attributes inherited from When::CalendarTypes::CalendarNote

#event

Attributes inherited from TM::ReferenceSystem

#domain, #domain_of_validity, #position

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

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

Class Method Summary collapse

Methods inherited from When::CalendarTypes::CalendarNote

#copy, #day, #duration, #enum_for, #include?, #month, #note?, #notes, #year

Methods inherited from TM::ReferenceSystem

#name

Methods inherited from BasicTypes::Object

#tap

Methods included from Parts::Resource

#[], #^, _extract_prefix, _instance, _parse, _path_with_prefix, _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

Class Method Details

._day_notes(notes, dates, conditions = {}) ⇒ Object

日の暦注



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/when_exe/region/japanese_notes.rb', line 640

def self._day_notes(notes, dates, conditions={})
  # 廿七宿
  m, l = [1,0].map {|f| dates.m_date.cal_date[1] * f}
  d    = (StarMansions[l==1 ? (conditions[:i27]||0) :
                              (conditions[:n27]||0)][m-1] + dates.m_date.cal_date[2] - 1) % 27
  notes['廿七宿'] ||= StarMansionIndex[d]

  # 甘露 / 金剛峯 / 羅刹
  w    = (dates.m_date.to_i + 1) % 7
  ['甘露', '金剛峯', '羅刹'].each do |c|
    notes[c] = c if d == WeekDepended[c][w]
  end

  # 三宝吉・神吉・雑事吉
  notes['神吉'] = notes['雑事吉'] = notes['三宝吉'] = nil   if notes[''  ] || notes[''  ]
  notes['神吉'] = notes['雑事吉']                   = nil   if notes['日食'] || notes['月食'] || notes['往亡']
  notes['三宝吉'] = nil if !notes['甘露'] && (notes['羅刹'] || notes['日食'] || notes['月食'])
  notes['三宝吉'] = notes['甘露'] ? '三宝吉' : nil if /\+/ =~ notes['三宝吉'].to_s
  notes['三宝吉'] = '三吉' if notes['三宝吉'] && dates.year >= 1185 # 鎌倉以降

  # 除手足甲 & 道虚
  y,m0,d0 = dates.m_date.cal_date
  notes['道虚']   = '道虚' if d0 % 6 == 0
  if (d0 == 29)
    m1 = (dates.m_date + When.Duration('P1D')).cal_date[1]
    unless m0 == m1
     # 晦日
     notes['除手足甲'] = '除手足甲' unless notes[''] || notes[''] || notes['凶会']
     notes['道虚']     = '道虚'
     misoka = true if m % 6 == 0  # 『現代こよみ読み解き事典』 for 不成就日
    end
  end

  # 仮名暦
  notes['赤舌'  ] ||= d0 == (m * 5 - 3) % 6 + 1 ? '赤舌' : nil
  notes['赤口'  ] ||= d0 == (m * 7 - 4) % 8 + 1 ? '赤口' : nil
  notes['不成就'] ||= d0 % 8 == [6,3,2,1,4,5][m % 6] || misoka ? '不成就' : nil
  notes['六曜'  ] ||= Rokuyo[(m + d0) % 6] if dates.year >= 1873 # 明治改暦以降
  notes
end

._month_notes(notes, dates, conditions = {}) ⇒ Object

月の暦注



633
634
635
636
# File 'lib/when_exe/region/japanese_notes.rb', line 633

def self._month_notes(notes, dates, conditions={})
  # 月名
  notes['月名'] ||= dates.o_date.name('month')
end