Class: When::TM::Calendar
- Inherits:
-
ReferenceSystem
- Object
- BasicTypes::Object
- Object
- ReferenceSystem
- When::TM::Calendar
- Includes:
- Spatial::Normalize, Temporal, Coordinates, When::TimeStandard::TimeBasis
- Defined in:
- lib/when_exe/tmreference.rb,
lib/when_exe/inspect.rb
Overview
暦
see gml schema
Direct Known Subclasses
CalendarTypes::Christian, CalendarTypes::EphemerisBased, CalendarTypes::TableBased
Constant Summary collapse
- HashProperty =
[:label, :referenceFrame, :timeBasis]
Constants included from Coordinates
Coordinates::Bahai, Coordinates::Chinese, Coordinates::Common, Coordinates::DefaultDateIndices, Coordinates::DefaultDayIndex, Coordinates::DefaultTimeIndices, Coordinates::Indian, Coordinates::Iranian, Coordinates::Javanese, Coordinates::MATCH, Coordinates::Mayan, Coordinates::PERIOD, Coordinates::PERIOD_NAME, Coordinates::PRECISION, Coordinates::PRECISION_NAME, Coordinates::Russian, Coordinates::Tibetan, Coordinates::VALUE, Coordinates::Yi
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 collapse
-
#diff_to_CE ⇒ Numeric
readonly
西暦との年次の相違(内部表現の0年に対応する西暦年) - additional attribute.
-
#epoch_in_CE ⇒ Numeric
readonly
西暦との年次の相違(外部表現の0年に対応する西暦年) - additional attribute.
-
#reference_frame ⇒ Array<When::TM::CalendarEra>
(also: #referenceFrame)
readonly
この暦と関連付けられた暦年代 (relation - Basis).
-
#time_basis ⇒ Array<When::TM::Clock>
(also: #timeBasis)
readonly
一暦日の中の時間位置を定めるために、この暦とともに使用する時計 (relation - Resolution).
Attributes included from When::TimeStandard::TimeBasis
Attributes inherited from ReferenceSystem
#domain_of_validity, #position
Attributes inherited from BasicTypes::Object
Attributes included from Parts::Resource
#_pool, #child, #keys, #locale, #namespace
Class Method Summary collapse
-
._setup_ ⇒ void
初期化.
Instance Method Summary collapse
-
#_new_month_(m) ⇒ Numeric
月初の通日.
-
#_to_month_number_(sdn) ⇒ Array<Numeric>
通日 - > [通月,月内日数,月の日数].
-
#date_trans(cal_date, time = nil, options = {}) ⇒ When::TM::JulianDate
(also: #dateTrans)
日付と時刻をユリウス日(When::TM::JulianDate)に変換する.
-
#jul_trans(jdt, options = {}) ⇒ When::TM::CalDate, When::TM::CalDateAndTime
(also: #julTrans, #^)
ユリウス日(When::TM::JulianDate)を日付に変換する.
-
#rate_of_clock ⇒ Numeric
時間の歩度.
-
#strftime ⇒ String
TemporalPosition#strftime のためのデフォルト書式.
-
#time_standard ⇒ When::TimeStandard?
時刻制 - additional attribute.
-
#to_cal_date(jdn) ⇒ Array<Numeric>
ユリウス日(Numeric)を日付に変換する.
-
#to_julian_date(cal_date) ⇒ Integer
日付をユリウス日(Numeric)に変換する.
-
#to_universal_time(cal_date, clk_time, clock = When::UTC) ⇒ Numeric
日付・時刻をUniversal Time(Numeric)に変換する.
Methods included from When::TimeStandard::TimeBasis
Methods included from Coordinates
Methods inherited from ReferenceSystem
Methods included from Parts::Resource
#[], _abbreviation_to_iri, _decode, _encode, _extract_prefix, _instance, _instantiate, _parse, _path_with_prefix, _replace_tags, _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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class When::Parts::Resource
Instance Attribute Details
#diff_to_CE ⇒ Numeric (readonly)
西暦との年次の相違(内部表現の0年に対応する西暦年) - additional attribute
171 172 173 |
# File 'lib/when_exe/tmreference.rb', line 171 def diff_to_CE @diff_to_CE end |
#epoch_in_CE ⇒ Numeric (readonly)
西暦との年次の相違(外部表現の0年に対応する西暦年) - additional attribute
164 165 166 |
# File 'lib/when_exe/tmreference.rb', line 164 def epoch_in_CE @epoch_in_CE end |
#reference_frame ⇒ Array<When::TM::CalendarEra> (readonly) Also known as: referenceFrame
マルチスレッド動作時 CalendarEra の生成で 本属性が更新される 参照・更新処理は synchronize { … } の … の部分に書く必要がある
この暦と関連付けられた暦年代 (relation - Basis)
The calendar eras associated with the calendar being described
131 132 133 |
# File 'lib/when_exe/tmreference.rb', line 131 def reference_frame @reference_frame end |
#time_basis ⇒ Array<When::TM::Clock> (readonly) Also known as: timeBasis
一暦日の中の時間位置を定めるために、この暦とともに使用する時計 (relation - Resolution)
The clock that is used with this calendar to define temporal position within a calendar day
141 142 143 |
# File 'lib/when_exe/tmreference.rb', line 141 def time_basis @time_basis end |
Class Method Details
._setup_ ⇒ void
本メソッドでマルチスレッド対応の管理変数の初期化を行っている。 このため、本メソッド自体はスレッドセーフでない。
This method returns an undefined value.
初期化
113 114 115 116 |
# File 'lib/when_exe/tmreference.rb', line 113 def self._setup_ @_lock_ = Mutex.new if When.multi_thread @_pool = {} end |
Instance Method Details
#_new_month_(m) ⇒ Numeric
月初の通日
275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/when_exe/tmreference.rb', line 275 def _new_month_(m) date = @base.map {|d| d||0} if @indices[-2].unit date[-2] += m _coordinates_to_number(*_decode(date)) else d0 = _coordinates_to_number(*_decode(date)) date[-3] += (m * @mean_month / @mean_year).floor - 1 d1 = _coordinates_to_number(*_decode(date)) date[-2] += m - ((d1 - d0) / @mean_month + 0.5).floor _coordinates_to_number(*_decode(date)) end end |
#_to_month_number_(sdn) ⇒ Array<Numeric>
通日 - > [通月,月内日数,月の日数]
298 299 300 |
# File 'lib/when_exe/tmreference.rb', line 298 def _to_month_number_(sdn) Residue.mod(sdn) {|m| _new_month(m)} end |
#date_trans(cal_date, time = nil, options = {}) ⇒ When::TM::JulianDate Also known as: dateTrans
日付と時刻をユリウス日(When::TM::JulianDate)に変換する
180 181 182 183 184 185 |
# File 'lib/when_exe/tmreference.rb', line 180 def date_trans(cal_date, time=nil, ={}) time = cal_date.clk_time if ((time == nil) && cal_date.kind_of?(DateAndTime)) frac = (time) ? time.universal_time : 0.0 jdn = to_julian_date(cal_date.cal_date) return JulianDate.universal_time((jdn - JulianDate::JD19700101) * Duration::DAY + frac, ) end |
#jul_trans(jdt, options = {}) ⇒ When::TM::CalDate, When::TM::CalDateAndTime Also known as: julTrans, ^
ユリウス日(When::TM::JulianDate)を日付に変換する
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/when_exe/tmreference.rb', line 196 def jul_trans(jdt, ={}) = TemporalPosition.() unless jdt.kind_of?(When::TimeValue) [:clock] ||= @time_basis unless rate_of_clock == 1.0 jdt = JulianDate.new(jdt, ) end = jdt._attr .delete(:era_name) .delete(:era) unless rate_of_clock == jdt.time_standard.rate_of_clock .delete(:time_standard) [:clock] = @time_basis || When::UTC jdt = JulianDate.dynamical_time(jdt.dynamical_time, {:time_standard=>time_standard}) end .update() [:frame] = self clock = Clock.get_clock_option() || jdt.clock if clock clock = When.Clock(clock) if clock.kind_of?(String) clock = clock._daylight(jdt.universal_time) if clock._need_validate frac = clock.universal_time(jdt.to_i) sdn, time = (jdt.universal_time - frac).divmod(Duration::DAY) [:clock] = clock cal_date = to_cal_date(sdn.to_i + JulianDate::JD19700101) cal_date[0] -= [:era_name][1] if [:era_name] DateAndTime.new(cal_date, time+frac, ) else cal_date = to_cal_date(jdt.to_i) cal_date[0] -= [:era_name][1] if [:era_name] CalDate.new(cal_date, ) end end |
#rate_of_clock ⇒ Numeric
時間の歩度
156 157 158 |
# File 'lib/when_exe/tmreference.rb', line 156 def rate_of_clock @time_basis ? @time_basis.time_standard.rate_of_clock : 1.0 end |
#strftime ⇒ String
TemporalPosition#strftime のためのデフォルト書式
295 296 297 |
# File 'lib/when_exe/inspect.rb', line 295 def strftime @strftime ||= '%Y-%m-%d' end |
#time_standard ⇒ When::TimeStandard?
時刻制 - additional attribute
148 149 150 |
# File 'lib/when_exe/tmreference.rb', line 148 def time_standard @time_basis ? @time_basis.time_standard : nil end |
#to_cal_date(jdn) ⇒ Array<Numeric>
ユリウス日(Numeric)を日付に変換する
239 240 241 |
# File 'lib/when_exe/tmreference.rb', line 239 def to_cal_date(jdn) _encode(_number_to_coordinates(jdn)) end |
#to_julian_date(cal_date) ⇒ Integer
日付をユリウス日(Numeric)に変換する
249 250 251 252 253 |
# File 'lib/when_exe/tmreference.rb', line 249 def to_julian_date(cal_date) date = _decode(cal_date) date[0] = +date[0] _coordinates_to_number(*date) end |
#to_universal_time(cal_date, clk_time, clock = When::UTC) ⇒ Numeric
日付・時刻をUniversal Time(Numeric)に変換する
263 264 265 266 267 |
# File 'lib/when_exe/tmreference.rb', line 263 def to_universal_time(cal_date, clk_time, clock=When::UTC) time = clk_time.dup time[0] += _coordinates_to_number(*_decode(cal_date)) clock.to_universal_time(time) - When::TM::JulianDate::JD19700101 * When::TM::Duration::DAY end |