Class: When::CalendarTypes::CalendarNote::Christian

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

Overview

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

Constant Summary collapse

NoteObjects =
[When::BasicTypes::M17n, [
  "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
  "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:[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)

Constants inherited from When::CalendarTypes::CalendarNote

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

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary collapse

Attributes inherited from When::CalendarTypes::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::CalendarTypes::CalendarNote

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

Methods inherited from TM::ReferenceSystem

#domain, #name

Methods included from Parts::Resource

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

Instance Attribute Details

#bInteger (readonly)

ベース

Returns:

  • (Integer)


584
585
586
# File 'lib/when_exe/region/christian.rb', line 584

def b
  @b
end

#cInteger (readonly)

月の位相の補正

Returns:

  • (Integer)


576
577
578
# File 'lib/when_exe/region/christian.rb', line 576

def c
  @c
end

#dInteger (readonly)

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

Returns:

  • (Integer)


560
561
562
# File 'lib/when_exe/region/christian.rb', line 560

def d
  @d
end

#fInteger (readonly)

満月補正フラグ

Returns:

  • (Integer)


588
589
590
# File 'lib/when_exe/region/christian.rb', line 588

def f
  @f
end

#gInteger (readonly)

ガード

Returns:

  • (Integer)


580
581
582
# File 'lib/when_exe/region/christian.rb', line 580

def g
  @g
end

#nInteger (readonly)

平年数

Returns:

  • (Integer)


568
569
570
# File 'lib/when_exe/region/christian.rb', line 568

def n
  @n
end

#sInteger (readonly)

置閏周期

Returns:

  • (Integer)


572
573
574
# File 'lib/when_exe/region/christian.rb', line 572

def s
  @s
end

#wInteger (readonly)

週日補正フラグ

Returns:

  • (Integer)


556
557
558
# File 'lib/when_exe/region/christian.rb', line 556

def w
  @w
end

#xInteger (readonly)

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

Returns:

  • (Integer)


564
565
566
# File 'lib/when_exe/region/christian.rb', line 564

def x
  @x
end

Instance Method Details

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

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



632
633
634
# File 'lib/when_exe/region/christian.rb', line 632

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

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

クリスマス

Parameters:

Returns:

  • (Integer)

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

  • (When::TM::CalDate)

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



599
600
601
602
603
# File 'lib/when_exe/region/christian.rb', line 599

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



614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/when_exe/region/christian.rb', line 614

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

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

固定祝日

Parameters:

Returns:

  • (String)

    祝日の名称

  • (nil)

    祝日に該当しない



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

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

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

移動祝日

Parameters:

Returns:

  • (String)

    祝日の名称

  • (nil)

    祝日に該当しない



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

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::Julian)
  Moveable_feasts[date.cal_date[-2..-1] + [date.to_i % 7]]
end