Module: Zakuro::Western
- Defined in:
- lib/zakuro/era/western/calendar.rb,
lib/zakuro/era/western/date_text.rb
Overview
Western 西暦
Defined Under Namespace
Modules: DateText, Type Classes: Calendar, Parameter
Constant Summary collapse
- DATE_START =
Returns グレゴリオ暦の開始日(ユリウス日).
{ # 通年ユリウス暦 Type::JULIAN => Date::JULIAN, # 通年グレゴリオ暦 Type::GREGORIAN => Date::GREGORIAN, # ユリウス暦/グレゴリオ暦 # # Date::ITALY は以下引用の通りにユリウス暦/グレゴリオ暦の改暦が行われるため矛盾はない # # ユリウス暦で1582年10月4日(わが天正10年9月18日)の翌日を10月15日としてグレゴリオ暦に改暦した。 # 9月朔まではユリウス暦日に対応させるべきであるが、計算の都合でこの頁からグレゴリオ暦に対応させてある。 # 念のため相当するユリウス暦日を記すと、天正10年正月朔は1月24日、2月朔は2月23日、3月朔は3月24日、 # 4月朔は4月23日、5月朔は5月22日、6月朔は6月20日、7月朔は7月20日、8月朔は8月18日、9月朔は9月17日である。 # 以下必要ならグレゴリオ暦日の10日前を求めればよい。(暦法編第3章のix : 第30表参照) # p.393 # # Date::ITALY は改暦による存在しない日付(1582-10-05 ~ 1852-10-14)でエラーが発生する # # ref: https://github.com/ruby/ruby/blob/487d96c6b1cd7f5d415dba27a9684b30dfa9afed/ext/date/date_core.c#L9237-L9249 # # * A Date object can be created with an optional argument, # * the day of calendar reform as a Julian day number, which # * should be 2298874 to 2426355 or negative/positive infinity. # * The default value is +Date::ITALY+ (2299161=1582-10-15). # * See also sample/cal.rb. # * # * $ ruby sample/cal.rb -c it 10 1582 # * October 1582 # * S M Tu W Th F S # * 1 2 3 4 15 16 # * 17 18 19 20 21 22 23 # * 24 25 26 27 28 29 30 # * 31 # Type::DEFAULT => Date::ITALY }.freeze
Class Method Summary collapse
-
.to_native_start(type:) ⇒ Integer
日付種別からRuby標準のグレゴリオ暦開始日を引き当てる.
-
.to_type(start:) ⇒ Symbol
Ruby標準のグレゴリオ暦開始日から日付種別を引き当てる.
Class Method Details
.to_native_start(type:) ⇒ Integer
日付種別からRuby標準のグレゴリオ暦開始日を引き当てる
71 72 73 |
# File 'lib/zakuro/era/western/calendar.rb', line 71 def to_native_start(type:) DATE_START.fetch(type, DATE_START[Type::DEFAULT]) end |
.to_type(start:) ⇒ Symbol
Ruby標準のグレゴリオ暦開始日から日付種別を引き当てる
82 83 84 |
# File 'lib/zakuro/era/western/calendar.rb', line 82 def to_type(start:) DATE_START.invert.fetch(start, Type::DEFAULT) end |