Class: When::CalendarNote::TranquilityWeek

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

Overview

Tranquility Week

Constant Summary collapse

Notes =

Tranquility Note

[When::BasicTypes::M17n, [
  "locale:[=en:, ja=ja:, alias]",
  "names:[Tranquility, 静かの海]",

  # Notes for year ----------------------------
  [When::BasicTypes::M17n,
    "names:[note for year=, 年の暦注=, *year]"
  ],

  # Notes for month ----------------------------
  [When::BasicTypes::M17n,
    "names:[note for month=, 月の暦注=, *month]",
    [When::BasicTypes::M17n,
      "names:[month name=en:Month, 月の名前=ja:%%<月_(暦)>, zh:該月的名稱=, *alias:Month=]",
      "[Archimedes,                        アルキメデス                                         ]",
      "[Brahe=en:Tycho_Brahe,              ブラーエ=ja:%%<ティコ・ブラーエ>                     ]",
      "[Copernicus=en:Nicolaus_Copernicus, コペルニクス=ja:%%<ニコラウス・コペルニクス>         ]",
      "[Darwin=en:Charles_Darwin,          ダーウィン=ja:%%<チャールズ・ダーウィン>             ]",
      "[Einstein=en:Albert_Einstein,       アインシュタイン=ja:%%<アルベルト・アインシュタイン> ]",
      "[Faraday=en:Michael_Faraday,        ファラデー=ja:%%<マイケル・ファラデー>               ]",
      "[Galileo=en:Galileo_Galilei,        ガリレオ=ja:%%<ガリレオ・ガリレイ>                   ]",
      "[Hippocrates,                       ヒポクラテス                                         ]",
      "[Imhotep,                           イムホテプ                                           ]",
      "[Jung=en:Carl_Jung,                 ユング=ja:%%<カール・グスタフ・ユング>               ]",
      "[Kepler=en:Johannes_Kepler,         ケプラー=ja:%%<ヨハネス・ケプラー>                   ]",
      "[Lavoisier=en:Antoine_Lavoisier,    ラヴォアジエ=ja:%%<アントワーヌ・ラヴォアジエ>       ]",
      "[Mendel=en:Gregor_Mendel,           メンデル=ja:%%<グレゴール・ヨハン・メンデル>         ]"
    ]
  ],

  # Notes for day ----------------------------
  [When::BasicTypes::M17n,
    "names:[note for day=, 日の暦注=, *day]",
    [When::BasicTypes::M17n,
      "names:[Week, 週, zh:星期]",
      [DayOfWeek, "label:[Friday,    金曜日, /date/day_names/5]", {'delta'=>  7}],
      [DayOfWeek, "label:[Saturday,  土曜日, /date/day_names/6]", {'delta'=>  7}],
      [DayOfWeek, "label:[Sunday,    日曜日, /date/day_names/0]", {'delta'=>  7}],
      [DayOfWeek, "label:[Monday,    月曜日, /date/day_names/1]", {'delta'=>  7}],
      [DayOfWeek, "label:[Tuesday,   火曜日, /date/day_names/2]", {'delta'=>  7}],
      [DayOfWeek, "label:[Wednesday, 水曜日, /date/day_names/3]", {'delta'=>  7}],
      [DayOfWeek, "label:[Thursday,  木曜日, /date/day_names/4]", {'delta'=>  7}],
      [DayOfWeek, "label:[Armstrong Day=en:Neil_Armstrong, アームストロングの日=ja:%%<ニール・アームストロング>]", {'delta'=> 366}],
      [DayOfWeek, "label:[Aldrin Day=en:Buzz_Aldrin,       オルドリンの日=ja:%%<バズ・オルドリン>]",               {'delta'=>1461}]
    ],

    "[Common_Week=]"
  ]
]]
IndexOfWeek =
[0, 1, 2, 3, 4, 5, 7, nil, 6]

Constants inherited from When::CalendarNote

Bahai, CalendarDepend, 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

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

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

convert any date to Tranquility calendar date



139
140
141
142
# File 'lib/when_exe/region/tranquility.rb', line 139

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

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

Just or last friday

Parameters:

Returns:



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/when_exe/region/tranquility.rb', line 91

def friday(date, parameter=nil)
  date  = _to_date_for_note(date)
  y,m,d = date.cal_date
  dow   = (+d-1) % 7
  if date.length(When::MONTH) == 29 && +d >= 28
    dow = (m == 8) ? (d*1 == 27 ? 6 : 7) :
                     (d   == 28 ? 6 : 7)
  end
  date -= When::P1D * dow unless dow == 0
  date.events = [@days_of_week[0]]
  date
end

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

What day is it the specified date?

Parameters:

Returns:



112
113
114
115
116
117
118
119
# File 'lib/when_exe/region/tranquility.rb', line 112

def week(date, base=nil)
  date   = _to_date_for_note(date)
  y,m,d  = date.cal_date
  dow    = d*0 == 0 ? (d<=28 ? (d-1) % 7 : d-22) : 8
  length = (base||date).length(When::MONTH) - 21
  index  = (length == 7 || m == 13) ? dow : IndexOfWeek[dow]
  {:value=>@days_of_week[dow], :position=>[index, length]}
end

#week_labels(date) ⇒ Array<When::CalendarNote::Week::DayOfWeek>

Week labels



128
129
130
131
132
133
# File 'lib/when_exe/region/tranquility.rb', line 128

def week_labels(date)
  date = _to_date_for_note(date)
  date.length(When::MONTH) == 28 ? @days_of_week.child[0...7] :
  date.month == 13               ? @days_of_week.child[0...8] :
                                   @days_of_week.child[0...6] + [@days_of_week.child[8], @days_of_week.child[6]]
end