Class: When::CalendarNote::Christian

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

Overview

キリスト教の暦注(クリスマスと復活祭)

Constant Summary collapse

Notes =
[When::BasicTypes::M17n, [
  "locale:[=en:, ja=ja:, alias]",
  "names:[Christian=en:Christianity, キリスト教]",

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

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

  # 日の暦注 ----------------------------
  [When::BasicTypes::M17n,
    "names:[note for day=, 日の暦注=, *day]",
    [When::BasicTypes::M17n, "names:[Week,           七曜]"      ],
    [When::BasicTypes::M17n, "names:[Easter,         復活祭]"    ],
    [When::BasicTypes::M17n, "names:[Christmas,      クリスマス]"],
    [When::BasicTypes::M17n, "names:[Fixed_feast=,   固定祝日=]" ],
    [When::BasicTypes::M17n, "names:[Moveable_feast, 移動祝日]"  ]
  ]
]]
Fixed_feasts =

固定祝日

{
  [ 1,  6] => "Epiphany",
  [ 3,  1] => "St.David's Day",
  [ 3, 17] => "St.Patrick's Day",
  [ 3, 25] => "Annunciation-Lady Day",
  [ 4, 23] => "St.George's Day",
  [ 6, 24] => "Midsummer Day",
  [ 9, 14] => "Holy Cross Day",
  [ 9, 29] => "Michaelmas Day",
  [11, 30] => "St.Andrew's Day",
  [12, 13] => "St.Lucia's Day",
  [12, 21] => "St.Thomas's Day",
# [12, 25] => "Christmas Day"
}
Moveable_feasts =

移動祝日

{
  # 復活祭からの日数による
  -63 => "Septuagesima Sunday",
  -56 => "Sexagesima Sunday",
  -49 => "Quinquagesima Sunday",
  -46 => "Ash Wednesday",
  -42 => "Quadragesima Sunday",
  -40 => "I Quatember",
  -35 => "Reminizer Sunday",
  -28 => "Oculi Sunday",
  -21 => "Laetare Sunday",
  -14 => "Judica Sunday",
   -7 => "Palmarum",
   -2 => "Good Friday",
#   0 => "Easter Day",
    7 => "Low Sunday",
   35 => "Rogation Sunday",
   39 => "Ascension Day",
   49 => "Whitsunday",
   53 => "II Quatember",
   56 => "Trinity Sunday",
   60 => "Corpus Christi",
}.update(moveable_feasts)
CalendarDepend =

暦法によってイベントの動作を変えるか否か

true

Constants inherited from When::CalendarNote

Bahai, 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

Constants included from Namespace

Namespace::DC, Namespace::DCQ, Namespace::DCT, Namespace::FOAF, Namespace::OWL, Namespace::RDF, Namespace::RDFC, Namespace::RDFS, Namespace::RSS, Namespace::XSD

Instance Attribute Summary collapse

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, #year

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, #parent, #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 Attribute Details

#bInteger (readonly)

ベース

Returns:

  • (Integer)


669
670
671
# File 'lib/when_exe/region/christian.rb', line 669

def b
  @b
end

#cInteger (readonly)

月の位相の補正

Returns:

  • (Integer)


661
662
663
# File 'lib/when_exe/region/christian.rb', line 661

def c
  @c
end

#dInteger (readonly)

最も遅い満月の3月0日からの日数

Returns:

  • (Integer)


645
646
647
# File 'lib/when_exe/region/christian.rb', line 645

def d
  @d
end

#fInteger (readonly)

満月補正フラグ

Returns:

  • (Integer)


673
674
675
# File 'lib/when_exe/region/christian.rb', line 673

def f
  @f
end

#gInteger (readonly)

ガード

Returns:

  • (Integer)


665
666
667
# File 'lib/when_exe/region/christian.rb', line 665

def g
  @g
end

#nInteger (readonly)

平年数

Returns:

  • (Integer)


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

def n
  @n
end

#sInteger (readonly)

置閏周期

Returns:

  • (Integer)


657
658
659
# File 'lib/when_exe/region/christian.rb', line 657

def s
  @s
end

#wInteger (readonly)

週日補正フラグ

Returns:

  • (Integer)


641
642
643
# File 'lib/when_exe/region/christian.rb', line 641

def w
  @w
end

#xInteger (readonly)

クリスマスの3月0日からの日数

Returns:

  • (Integer)


649
650
651
# File 'lib/when_exe/region/christian.rb', line 649

def x
  @x
end

Instance Method Details

#_delta(parameter = nil) ⇒ Object Also known as: christmas_delta, easter_delta

イベントの標準的な間隔を返す



728
729
730
# File 'lib/when_exe/region/christian.rb', line 728

def _delta(parameter=nil)
  return When::P1Y
end

#christmas(date, frame = nil) ⇒ Integer, When::TM::CalDate

クリスマス

Parameters:

Returns:

  • (Integer)

    クリスマスのユリウス通日(dateが西暦の年数の場合)

  • (When::TM::CalDate)

    クリスマスのWhen::TM::CalDate(yearがWhen::TM::TemporalPositionの場合)



695
696
697
698
699
# File 'lib/when_exe/region/christian.rb', line 695

def christmas(date, frame=nil)
  _event(date, 'christmas', frame) do |year, frame|
    @x - 1 + frame._coordinates_to_number(year, 2, 0)
  end
end

#easter(date, frame = nil) ⇒ Integer, When::TM::CalDate

復活祭

Parameters:

Returns:

  • (Integer)

    復活祭のユリウス通日(dateが西暦の年数の場合)

  • (When::TM::CalDate)

    復活祭のWhen::TM::CalDate(yearがWhen::TM::TemporalPositionの場合)



710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/when_exe/region/christian.rb', line 710

def easter(date, frame=nil)
  _event(date, 'easter', frame) do |year, frame|
    golden = (year+@b) % @s + 1
    m      = (frame._lunar_equation(year) + 11*golden + @c) % 30
    if @f == 0
      m += 1 if m==0 || m==1 && golden>=@n
    else
      m += (golden-1) / @f
      m -= 30 if m>=@n
    end
    result  = frame._coordinates_to_number(year, 2, 0) + @d - 1 - m
    result += @g - (result-@w) % 7 if @w<7
    result + frame._easter_delay(year)
  end
end

#fixed_feast(date, frame = nil) ⇒ String?

固定祝日

Parameters:

Returns:

  • (String)

    祝日の名称

  • (nil)

    祝日に該当しない



746
747
748
749
# File 'lib/when_exe/region/christian.rb', line 746

def fixed_feast(date, frame=nil)
  date = When.Calendar(frame||'Gregorian') ^ date unless date.frame.kind_of?(When::CalendarTypes::Christian)
  Fixed_feasts[date.cal_date[-2..-1]]
end

#moveable_feast(date, frame = nil) ⇒ String?

移動祝日

Parameters:

Returns:

  • (String)

    祝日の名称

  • (nil)

    祝日に該当しない



759
760
761
762
763
764
# File 'lib/when_exe/region/christian.rb', line 759

def moveable_feast(date, frame=nil)
  result = Moveable_feasts[date.to_i - easter(date, frame).to_i]
  return result if result
  date = When.Calendar(frame||'Gregorian') ^ date unless date.frame.kind_of?(When::CalendarTypes::Christian)
  Moveable_feasts[date.cal_date[-2..-1] + [date.to_i % 7]]
end

#week(date, base = nil) ⇒ When::Coordinates::Residue

七曜

Parameters:

Returns:



682
683
684
# File 'lib/when_exe/region/christian.rb', line 682

def week(date, base=nil)
  When.Residue('Week')[date.to_i % 7]
end