Class: When::CalendarTypes::Gregorian

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

Overview

Gregorian Calendar

Direct Known Subclasses

Civil

Constant Summary

Constants included from When::Coordinates

When::Coordinates::Bahai, When::Coordinates::CommonResidue, When::Coordinates::DefaultDateIndices, When::Coordinates::DefaultDayIndex, When::Coordinates::DefaultTimeIndices, When::Coordinates::IndianCities, When::Coordinates::Javanese, When::Coordinates::MATCH, When::Coordinates::Mayan, When::Coordinates::PERIOD, When::Coordinates::PERIOD_NAME, When::Coordinates::PRECISION, When::Coordinates::PRECISION_NAME, When::Coordinates::Tibetan, When::Coordinates::VALUE, When::Coordinates::Yi

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary

Attributes inherited from TM::Calendar

#reference_frame, #time_basis

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TM::Calendar

#_new_month_, _setup_, #_to_month_number_, #date_trans, #jul_trans, #rate_of_clock, #time_standard, #to_cal_date, #to_julian_date, #to_universal_time

Methods included from TimeStandard::TimeBasis

#_normalize_time_basis

Methods included from When::Coordinates

to_deg, to_dms

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

Class Method Details

.diff(jdn) ⇒ Integer

通日 - > ユリウス暦とグレゴリオ暦の差

Parameters:

  • jdn (Integer)

    通日

Returns:

  • (Integer)

    ユリウス暦とグレゴリオ暦の差



205
206
207
208
209
# File 'lib/when_exe/region/christian.rb', line 205

def self.diff(jdn)
  div, mod = (jdn - 77528).divmod(36524.25)
  c = div - 45
  (3*(c-3)).div(4)+1
end

Instance Method Details

#_coordinates_to_number(y, m, d) ⇒ Integer

年月日 -> 通日

Parameters:

  • y (Numeric)

  • m (Integer)

    月 (0 始まり)

  • d (Integer)

    日 (0 始まり)

Returns:

  • (Integer)

    通日



219
220
221
222
# File 'lib/when_exe/region/christian.rb', line 219

def _coordinates_to_number(y,m,d)
  c = ((m < 2) ? +y-1 : +y).to_i.div(100)
  super - ((3*(c-3)).div(4)+1)
end

#_length(date) ⇒ Integer #_length(date) ⇒ Integer

暦要素数

Overloads:

  • #_length(date) ⇒ Integer

    Returns 12 (=その年の月数).

    Parameters:

    • date (Array<Integer>)

      ( 年 )

    Returns:

    • (Integer)

      12 (=その年の月数)

  • #_length(date) ⇒ Integer
    Note:

    月は 0 始まりの通番

    Returns その年月の日数.

    Parameters:

    • date (Array<Integer>)

      ( 年, 月 )

    Returns:

    • (Integer)

      その年月の日数



248
249
250
251
252
# File 'lib/when_exe/region/christian.rb', line 248

def _length(date)
  yy, mm = date
  return 28 if (((yy % 400) != 0) && ((yy % 100) == 0) && (mm == 1))
  return super
end

#_lunar_equation(year) ⇒ Integer

Note:

太陽暦日の補正も、本メソッドで行う

太陰方程式

Parameters:

  • year (Numeric)

    西暦の年数

Returns:

  • (Integer)

    19年7閏のペースに対する満月の日付の補正量



260
261
262
263
# File 'lib/when_exe/region/christian.rb', line 260

def _lunar_equation(year)
  h = +year.div(100)
  -h + h.div(4) + (8*(h+11)).div(25) - 3
end

#_number_to_coordinates(jdn) ⇒ Array<Integer>

通日 - > 年月日

Parameters:

  • jdn (Integer)

    通日

Returns:

  • (Array<Integer>)
    y, m, d

    y 年 m 月 (0 始まり) d 日 (0 始まり)



233
234
235
# File 'lib/when_exe/region/christian.rb', line 233

def _number_to_coordinates(jdn)
  super(jdn + Gregorian.diff(jdn))
end