Class: When::TM::ClockTime
- Inherits:
-
TemporalPosition
- Object
- TemporalPosition
- When::TM::ClockTime
- Defined in:
- lib/when_exe/tmposition.rb,
lib/when_exe/inspect.rb
Overview
時刻
see gml schema
Constant Summary
Constants inherited from TemporalPosition
TemporalPosition::AMPM, TemporalPosition::Format, TemporalPosition::HashProperty
Constants included from Coordinates
Coordinates::Bahai, Coordinates::CommonResidue, Coordinates::DefaultDateIndex, Coordinates::DefaultTimeIndex, Coordinates::IndianCities, Coordinates::Javanese, Coordinates::MATCH, Coordinates::Mayan, Coordinates::PERIOD, Coordinates::PERIOD_NAME, Coordinates::PRECISION, Coordinates::PRECISION_NAME, Coordinates::VALUE, Coordinates::Yi
Constants included from When
CENTURY, DAY, DECADE, DurationP1D, DurationP1M, DurationP1W, DurationP1Y, EUCJP, HOUR, MINUTE, MONTH, SECOND, STRING, SYSTEM, SourceURI, When::TimeValue, UTF8, VERSION, W31J, WEEK, YEAR
Constants included from Parts::Resource
Parts::Resource::LabelProperty, Parts::Resource::Prefix, Parts::Resource::PrefixIndex, Parts::Resource::PrefixKeys, Parts::Resource::PrefixValues
Constants included from IndeterminateValue
IndeterminateValue::After, IndeterminateValue::Before, IndeterminateValue::I, IndeterminateValue::Max, IndeterminateValue::Min, IndeterminateValue::Now, IndeterminateValue::S, IndeterminateValue::Unknown
Instance Attribute Summary collapse
-
#clk_time ⇒ Array<Numeric>
(also: #clkTime)
readonly
時刻要素.
Attributes inherited from TemporalPosition
#events, #frame, #indeterminated_position, #location, #options, #precision, #query, #trans
Attributes included from Parts::Resource
#_pool, #child, #keys, #locale, #namespace
Instance Method Summary collapse
-
#_copy(options = {}) ⇒ Object
protected 属性のコピー.
-
#_time_to_s(precision = @precision) ⇒ String
protected.
-
#_to_hash_value(options = {}) ⇒ Object
to_hash のための要素生成.
-
#carry ⇒ Numeric
繰り上がり.
-
#hour(d = 0) ⇒ Numeric
時.
-
#initialize(time, options = {}) ⇒ ClockTime
constructor
オブジェクトの生成.
-
#minute(d = 0) ⇒ Numeric
(also: #min)
分.
-
#name(index, format = nil) ⇒ When::BasicTypes::M17n
要素の多言語対応文字列化.
-
#second(d = 0) ⇒ Numeric
(also: #sec)
秒.
-
#to_m17n(precision = @precision) ⇒ When::BasicTypes::M17n
多言語対応文字列化 - When.exe Standard Representation により多言語対応文字列化する.
-
#to_s(precision = @precision) ⇒ String
文字列化 - When.exe Standard Representation により文字列化する.
-
#universal_time ⇒ Numeric
内部時間.
-
#value(index) ⇒ Numeric
要素の参照.
Methods inherited from TemporalPosition
#+, #+@, #-, #<=>, #[], #^, #_attr, _instance, #_notes, _options, _setup_, #_to_hash, #_to_s, #calendar_name, #clock_name, #copy, #dynamical_time, #floor, #has_next?, #has_time?, #include?, #is?, #month_included, #note?, #notes, #period, #prev, #rate_of_clock, #reference_label, #scan, #strftime, #succ, #term, #time_standard, #to_clock_time, #to_date, #to_date_time, #to_date_uri, #to_f, #to_i, #to_residue, #to_time, #to_uri, #week_included, #year_included
Methods included from Coordinates
Methods included from When
Calendar, CalendarEra, CalendarNote, Clock, Duration, M17n, MonthName, Pair, Residue, Resource, TemporalPosition, _free_conv, _parse, _setup_, at, client, config, era, free_conv, m17n, now, server, today, utc, when?
Methods included from TemporalPosition::Conversion
Methods included from Parts::Resource
#[], #^, _extract_prefix, _instance, _parse, _path_with_prefix, #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
Constructor Details
#initialize(time, options = {}) ⇒ ClockTime
オブジェクトの生成
1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 |
# File 'lib/when_exe/tmposition.rb', line 1285 def initialize(time, ={}) # 参照系の取得 @frame = ([:frame] || Clock.local_time || When.utc) @frame = When.Clock(@frame) if (@frame.kind_of?(String)) .delete(:frame) # 時刻表現の解読 ( Time Zone の解釈 ) if (time.kind_of?(String)) case time when /^([-+])?(\d{2,}?):?(\d{2})?:?(\d{2}(\.\d+)?)?$/ sign, hh, mm, ss = $~[1..4] time = @frame._validate([0,0,0,0], [0, -(sign.to_s + "0" + hh.to_s).to_i, -(sign.to_s + "0" + mm.to_s).to_i, Pair._en_number(-(sign.to_s + "0" + ss.to_s).to_f)]) time[0] = Pair.new(0, time[0].to_i) if (time[0] != 0) when /^Z$/ time = [0,0,0,0] else raise ArgumentError, "Invalid Time Format" end end @clk_time = time # 分解能 @precision = @frame._precision(time, .delete(:precision)) super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class When::TM::TemporalPosition
Instance Attribute Details
Instance Method Details
#_copy(options = {}) ⇒ Object
protected 属性のコピー
1265 1266 1267 1268 1269 1270 1271 1272 1273 |
# File 'lib/when_exe/tmposition.rb', line 1265 def _copy(={}) @clk_time = [:time] if (.key?(:time)) @frame = [:clock] if (.key?(:clock)) if (.key?(:tz_prop)) @frame = @frame.dup @frame.tz_prop = [:tz_prop] end return super end |
#_time_to_s(precision = @precision) ⇒ String
protected
時間帯以外の部分の文字列化
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 |
# File 'lib/when_exe/inspect.rb', line 826 def _time_to_s(precision=@precision) terms = [] format = '' format += Pair::DL2[@clk_time[0] * 0] || ':' if @frame.pair[0] || @clk_time[0].kind_of?(Pair) # 時分 digits = [@clk_time.length-2, precision].min if digits > 0 terms += @clk_time[1..-1] format += "%02d:" * digits format = format[0..-2] if precision == digits end # 秒 digits = [precision - @clk_time.length + 1, STRING-SECOND].min if digits >= 0 terms << @clk_time[-1] format += (digits == 0) ? "%02d" : "%02.#{digits}f" end # 結果 time = Pair._format([format] + terms) time.sub(/([^\d])(\d)\./, '\10\2.') end |
#_to_hash_value(options = {}) ⇒ Object
to_hash のための要素生成
854 855 856 |
# File 'lib/when_exe/inspect.rb', line 854 def _to_hash_value(={}) clk_time.map {|e| _m17n_form(e, ) } end |
#carry ⇒ Numeric
繰り上がり
1248 1249 1250 |
# File 'lib/when_exe/tmposition.rb', line 1248 def carry return @clk_time[0] end |
#hour(d = 0) ⇒ Numeric
時
789 790 791 |
# File 'lib/when_exe/inspect.rb', line 789 def hour(d=0) @clk_time[HOUR+d] end |
#minute(d = 0) ⇒ Numeric Also known as: min
分
800 801 802 |
# File 'lib/when_exe/inspect.rb', line 800 def minute(d=0) @clk_time[MINUTE+d] end |
#name(index, format = nil) ⇒ When::BasicTypes::M17n
要素の多言語対応文字列化
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
# File 'lib/when_exe/inspect.rb', line 742 def name(index, format=nil) digit = _digit(index) {|digit| digit > DAY} coordinate = @clk_time[digit] return m17n(format % coordinate) if format indices = @frame.indices[digit-1] if indices trunk = indices.trunk branch = indices.branch end format = branch ? m17n("%02d:") : "%02d" return m17n(format % coordinate) unless trunk trunk = trunk[coordinate * 1] return m17n(trunk) unless branch return trunk.prefix(branch[coordinate * 0]) end |
#second(d = 0) ⇒ Numeric Also known as: sec
秒
812 813 814 |
# File 'lib/when_exe/inspect.rb', line 812 def second(d=0) @clk_time[SECOND+d] end |
#to_m17n(precision = @precision) ⇒ When::BasicTypes::M17n
多言語対応文字列化 - When.exe Standard Representation により多言語対応文字列化する
765 766 767 768 769 |
# File 'lib/when_exe/inspect.rb', line 765 def to_m17n(precision=@precision) time = m17n('T' + _time_to_s(precision)) time += @frame.zone if (@frame && !@frame.equal?(Clock.local_time)) return time end |
#to_s(precision = @precision) ⇒ String
文字列化 - When.exe Standard Representation により文字列化する
777 778 779 780 781 |
# File 'lib/when_exe/inspect.rb', line 777 def to_s(precision=@precision) time = 'T' + _time_to_s(precision) time += @frame.zone if (@frame && !@frame.equal?(Clock.local_time)) return time end |
#universal_time ⇒ Numeric
内部時間
1237 1238 1239 1240 |
# File 'lib/when_exe/tmposition.rb', line 1237 def universal_time raise NameError, "Temporal Reference System is not defined" unless @frame @universal_time ||= @frame.to_universal_time(@clk_time) end |