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]",

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

  # 月の暦注 ----------------------------
  [When::BasicTypes::M17n,
    "names:[month]",
    [When::BasicTypes::M17n,
      "names:[Month]"
    ]
  ],

  # 日の暦注 ----------------------------
  [When::BasicTypes::M17n,
    "names:[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

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

#bInteger (readonly)

ベース

Returns:

  • (Integer)


663
664
665
# File 'lib/when_exe/region/christian.rb', line 663

def b
  @b
end

#cInteger (readonly)

月の位相の補正

Returns:

  • (Integer)


655
656
657
# File 'lib/when_exe/region/christian.rb', line 655

def c
  @c
end

#dInteger (readonly)

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

Returns:

  • (Integer)


639
640
641
# File 'lib/when_exe/region/christian.rb', line 639

def d
  @d
end

#fInteger (readonly)

満月補正フラグ

Returns:

  • (Integer)


667
668
669
# File 'lib/when_exe/region/christian.rb', line 667

def f
  @f
end

#gInteger (readonly)

ガード

Returns:

  • (Integer)


659
660
661
# File 'lib/when_exe/region/christian.rb', line 659

def g
  @g
end

#nInteger (readonly)

平年数

Returns:

  • (Integer)


647
648
649
# File 'lib/when_exe/region/christian.rb', line 647

def n
  @n
end

#sInteger (readonly)

置閏周期

Returns:

  • (Integer)


651
652
653
# File 'lib/when_exe/region/christian.rb', line 651

def s
  @s
end

#wInteger (readonly)

週日補正フラグ

Returns:

  • (Integer)


635
636
637
# File 'lib/when_exe/region/christian.rb', line 635

def w
  @w
end

#xInteger (readonly)

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

Returns:

  • (Integer)


643
644
645
# File 'lib/when_exe/region/christian.rb', line 643

def x
  @x
end

Instance Method Details

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

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



722
723
724
# File 'lib/when_exe/region/christian.rb', line 722

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の場合)



689
690
691
692
693
# File 'lib/when_exe/region/christian.rb', line 689

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の場合)



704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
# File 'lib/when_exe/region/christian.rb', line 704

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)

    祝日に該当しない



740
741
742
743
# File 'lib/when_exe/region/christian.rb', line 740

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)

    祝日に該当しない



753
754
755
756
757
758
# File 'lib/when_exe/region/christian.rb', line 753

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:



676
677
678
# File 'lib/when_exe/region/christian.rb', line 676

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