Class: When::CalendarNote::ChineseLuniSolar

Inherits:
When::CalendarNote show all
Defined in:
lib/when_exe/region/chinese/notes.rb

Overview

暦月の暦注

Direct Known Subclasses

ChineseSolar

Constant Summary collapse

Holidays =

節日の日付

{
  [1, 1] => When.M17n('ChineseLuniSolarHoliday::元日'),
  [1, 7] => When.M17n('ChineseLuniSolarHoliday::人日'),
  [1,15] => When.M17n('ChineseLuniSolarHoliday::小正月'),
  [3, 3] => When.M17n('ChineseLuniSolarHoliday::弥生節句'),
  [5, 5] => When.M17n('ChineseLuniSolarHoliday::端午節句'),
  [7, 7] => When.M17n('ChineseLuniSolarHoliday::七夕節句'),
  [7,15] => When.M17n('ChineseLuniSolarHoliday::お盆'),
  [8, 1] => When.M17n('ChineseLuniSolarHoliday::田実節句'),
  [9, 9] => When.M17n('ChineseLuniSolarHoliday::重陽節句')
}
Notes =

年月日の暦注

[When::BasicTypes::M17n, [
  "locale:[=ja:, en=en:, zh=zh:, alias=en:]",
  "names:[暦月の暦注=, LuniSolarNote=]",

  # 年の暦注 ----------------------------
  [When::BasicTypes::M17n,
    "names:[年の暦注=, note for year=, prefix:YearNote=, *alias:year=]",
    [When::BasicTypes::M17n,
      "names:[年の暦注=, note for year=, *alias:Year=]"
    ]
  ],

  # 月の暦注 ----------------------------
  [When::BasicTypes::M17n,
    "names:[月の暦注=, note for month=, prefix:MonthNote=, *alias:month=]",
    [When::BasicTypes::M17n,
      "names:[月の名前=ja:%%<月_(暦)>, month name=en:Month, 該月的名稱=, *alias:Month=]"
    ]
  ],

  # 日の暦注 ----------------------------
  [When::BasicTypes::M17n,
    "names:[日の暦注=, note for day=, prefix:DayNote=, *alias:day]",
     "[週,         *Week,                           星期      ]", # 七曜
     "[干支,       *StemBranch=en:Sexagenary_cycle, 干支      ]", # 六十干支
     "[二十四節気, *SolarTerm=en:Solar_term,        節気=zh:%%<节气>]", # 二十四節気
     "[没=,        *Motsu=,                         没=       ]", # 没
     "[節日=,      *Holiday=,                       歲時節日= ]"  # 節句など
  ]
]]

Constants inherited from When::CalendarNote

Bahai, CalendarDepend, Chinese, CommonWithRokuyo, CommonWithSovietFiveDay, CommonWithSovietSixDay, Default, HashProperty, Javanese, JulianDay, Mayan, Tibetan, Yis

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 When::CalendarNote

#event

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 When::CalendarNote

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

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

#_day_notes(date, options = {}) ⇒ Hash

日の暦注

Parameters:

Returns:

  • (Hash)

    暦注名=>暦注値



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/when_exe/region/chinese/notes.rb', line 174

def _day_notes(date, options={})
  s_date = When.when?(date.to_cal_date.to_s,
    {:frame=>date.frame,
     :clock=>(date.frame.kind_of?(When::CalendarTypes::EphemerisBasedSolar) || !date.frame.twin ?
        date.frame :
        When.Calendar(date.frame.twin))._time_basis[0]
    })

  # 没
  notes   = {}
  longitude, motsu = SolarTerms.new('formula'=>date.frame.formula[0]).position(s_date)
  if motsu == 0
    notes[''] = '' unless date.most_significant_coordinate >= 1685 && date.frame.iri =~ /JapaneseTwin/
    return notes
  end

  # 廿四節気
  div, mod = longitude.divmod(15)
  if mod == 0
    note = (div - 21) % 24
    div, mod = note.divmod(2)
    notes['二十四節気'] ||= 
     When.Resource(date.frame.iri =~ /戊寅|麟徳|儀鳳/ ? '_co:Common?V=0618' : '_co:Common')['二十四節気::*'][(note-3) % 24]
  end
  notes
end

#_normalize(args = [], options = {}) ⇒ Object

オブジェクトの正規化



161
162
163
164
# File 'lib/when_exe/region/chinese/notes.rb', line 161

def _normalize(args=[], options={})
  @_all_keys  ||= [%w(Year), %w(Month), %w(Week StemBranch SolarTerm Holiday)]
  super
end

#holiday(date, options = {}) ⇒ When::BasicTypes::M17n

Parameters:

Returns:



156
157
158
# File 'lib/when_exe/region/chinese/notes.rb', line 156

def holiday(date, options={})
  Holidays[[+date.cal_date[When::MONTH-1], date.cal_date[When::DAY-1]]]
end

#motsu(date, options = {}) ⇒ When::BasicTypes::M17n

Parameters:

Returns:



144
145
146
# File 'lib/when_exe/region/chinese/notes.rb', line 144

def motsu(date, options={})
  _day_notes(date, options)['']
end

#solarterm(date, options = {}) ⇒ When::Coordinates::Residue

二十四節気

Parameters:

Returns:



132
133
134
# File 'lib/when_exe/region/chinese/notes.rb', line 132

def solarterm(date, options={})
  _day_notes(date, options)['二十四節気']
end

#stembranch(date, options = {}) ⇒ When::Coordinates::Residue

日の干支

Parameters:

Returns:



120
121
122
# File 'lib/when_exe/region/chinese/notes.rb', line 120

def stembranch(date, options={})
  When.Residue('干支')[(date.to_i-11) % 60]
end

#week(date, options = {}) ⇒ When::Coordinates::Residue

七曜

Parameters:

Returns:



108
109
110
# File 'lib/when_exe/region/chinese/notes.rb', line 108

def week(date, options={})
  When.Residue('Week')[date.to_i % 7]
end

#year(date, options = {}) ⇒ When::Coordinates::Residue

年の干支

Parameters:

Returns:



96
97
98
# File 'lib/when_exe/region/chinese/notes.rb', line 96

def year(date, options={})
  When.Residue('干支')[(date.most_significant_coordinate-4) % 60]
end