Class: When::CalendarNote::WorldWeek

Inherits:
Week show all
Defined in:
lib/when_exe/region/world.rb

Overview

世界暦の暦週

Direct Known Subclasses

DarianWeek

Constant Summary collapse

Notes =

暦注要素の定義

[When::BasicTypes::M17n, [
  "locale:[=en:, ja=ja:, alias]",
  "names:[World]",

  # 年の暦注 ----------------------------
  [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]",
      [DayOfWeek, "label:[Sunday,    日曜日]", {'delta'=>7}],
      [DayOfWeek, "label:[Monday,    月曜日]", {'delta'=>7}],
      [DayOfWeek, "label:[Tuesday,   火曜日]", {'delta'=>7}],
      [DayOfWeek, "label:[Wednesday, 水曜日]", {'delta'=>7}],
      [DayOfWeek, "label:[Thursday,  木曜日]", {'delta'=>7}],
      [DayOfWeek, "label:[Friday,    金曜日]", {'delta'=>7}],
      [DayOfWeek, "label:[Saturday,  土曜日]", {'delta'=>7}],
      [DayOfWeek, "label:[Worldsday, 週外日]", {'delta'=>183}],
    ],

    "[Common_Week]"
  ]
]]
FirstDayOfWeek =
[0, 3, 5] * 4
ExtraDayInYear =
{
  [ 6, 31] => 7,
  [12, 31] => 7
}
WeekLength =
{
  [ 5, 31] => 8,
  [ 6, 31] => 8,
  [11, 31] => 8,
  [12, 31] => 8
}

Constants inherited from When::CalendarNote

Bahai, CalendarDepend, Chinese, CommonWithRokuyo, CommonWithSovietFiveDay, CommonWithSovietSixDay, Default, Javanese, JulianDay, Mayan, Tibetan, Yis

Constants included from Parts::Resource

Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty

Instance Attribute Summary

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 Week

#_column_for_week_included, #_range_for_week_included, #common_week, #week_labels

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 Method Details

#_to_date_for_note(date) ⇒ Object

暦日を当該暦注計算用クラスに変換



143
144
145
146
# File 'lib/when_exe/region/world.rb', line 143

def _to_date_for_note(date)
  date = When::World ^ date unless date.frame.equal?(When::World)
  date
end

#week(date, base = nil) ⇒ Hash<:value=>When::CalendarNote::Week::DayOfWeek, :position=>Array<Integer>>

この日は何曜?

Parameters:

Returns:



131
132
133
134
135
136
137
# File 'lib/when_exe/region/world.rb', line 131

def week(date, base=nil)
  date    = _to_date_for_note(date)
  y, m, d = date.cal_date
  index   = ExtraDayInYear[[m,d]] || (FirstDayOfWeek[m-1] + d - 1) % 7
  length  = WeekLength[[m, (base||date).length(When::MONTH)]] || 7
  {:value=>@days_of_week[index], :position=>[index, length]}
end

#week_day(date, parameter = nil) ⇒ When::TM::TemporalPosition

Note:

week_day は sunday, monday, tuesday, wednesday, thursday, friday, saturday に読み替えてください。

Parameters:

Returns:



# File 'lib/when_exe/region/world.rb', line 98

#worldsday(date, parameter = nil) ⇒ When::TM::TemporalPosition

当日または直前の worldsday の日

Parameters:

Returns:



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/when_exe/region/world.rb', line 85

def worldsday(date, parameter=nil)
  event_name = 'worldsday'
  date  = When.Calendar('World').jul_trans(date, {:events=>event_name})
  y,m,d = date.cal_date
  h, m  = (m-1).divmod(6)
  return date if m == 5 && d == 31
  dow   = [0, 31, 61, 91, 122, 152][m] + d
  dow  += 182 if h == 1 && When.Calendar('World')._sum([y]) == 365
  date += When::TM::PeriodDuration.new([0,0,-dow])
  date.events = [event_name]
  date
end