Class: When::TM::ClockTime
- Inherits:
-
TemporalPosition
- Object
- TemporalPosition
- When::TM::ClockTime
- Defined in:
- lib/when_exe/tmptypes.rb,
lib/when_exe/inspect.rb
Overview
時刻
see gml schema
Constant Summary
Constants inherited from TemporalPosition
TemporalPosition::AMPM, TemporalPosition::Format
Constants included from Coordinates
Coordinates::Bahai, Coordinates::Chinese, Coordinates::Common, Coordinates::DefaultDateIndices, Coordinates::DefaultDayIndex, Coordinates::DefaultTimeIndices, Coordinates::Indian, Coordinates::Iranian, Coordinates::Javanese, Coordinates::LocationTable, 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 When
AUTHOR, CENTURY, COPYRIGHT, DAY, DECADE, EUCJP, HOUR, MINUTE, MONTH, MinusInfinity, Month, P1D, P1M, P1W, P1Y, PT1H, PT1M, PT1S, PlusInfinity, RootDir, SECOND, STRING, SYSTEM, SourceURI, When::TimeValue, UTF8, VERSION, W31J, WEEK, Week, YEAR, YEARS
Constants included from Namespace
Namespace::DC, Namespace::DCQ, Namespace::DCT, Namespace::FOAF, Namespace::OWL, Namespace::RDF, Namespace::RDFC, Namespace::RDFS, Namespace::RSS, Namespace::XSD
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
#child, #keys, #locale, #namespace
Instance Method Summary collapse
-
#carry ⇒ Numeric
繰り上がり.
-
#hour(d = 0) ⇒ Numeric
時.
-
#initialize(time, options = {}) ⇒ ClockTime
constructor
オブジェクトの生成.
-
#local_time(sdn = nil) ⇒ Numeric
内部時間(ローカル).
-
#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(sdn = nil) ⇒ Numeric
内部時間.
-
#value(index) ⇒ Numeric
要素の参照.
Methods inherited from TemporalPosition
#+, #+@, #-, #<=>, #==, #[], #^, _instance, _instance_element, #_notes, _setup_, _setup_info, _temporal_position, #_to_h, #apply_delayed_options, #calendar_name, #clock_name, #copy, #dynamical_time, #floor, format, #has_next?, #has_time?, #include?, #inspect, #is?, #month_included, #note?, #notes, #period, #rate_of_clock, #reference_label, #scan, #strftime, #time_standard, #to_clock_time, #to_date, #to_datetime, #to_f, #to_i, #to_residue, #to_time, #to_uri, #to_uri_escape, #week_included, #year_included
Methods included from Coordinates
Methods included from When
Border, Calendar, CalendarEra, CalendarNote, Clock, Duration, Index, Location, M17n, MonthName, Pair, Residue, Resource, TemporalPosition, Wikipedia, _const_missing, _setup_, _setup_info, at, client, column, const_missing, date_or_era, era, free_conv, m17n, now, server, strptime, today, when?, where?
Methods included from TemporalPosition::Conversion
Methods included from Parts::Resource
#[], #^, _instance, _setup_, _setup_info, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #parent, #registered?, root_dir
Methods included from Parts::Resource::Pool
Constructor Details
#initialize(time, options = {}) ⇒ ClockTime
オブジェクトの生成
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'lib/when_exe/tmptypes.rb', line 452 def initialize(time, ={}) # 参照系の取得 @frame = [:frame] || Clock.local_time @frame = When.Clock(@frame) if (@frame.kind_of?(String)) .delete(:frame) # 時刻表現の解読 ( Time Zone の解釈 ) if (time.kind_of?(String)) case time when /\A([-+])?(\d{2,}?):?(\d{2})?:?(\d{2}(\.\d+)?)?\z/ 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 /\AZ\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
#carry ⇒ Numeric
繰り上がり
412 413 414 |
# File 'lib/when_exe/tmptypes.rb', line 412 def carry return @clk_time[0] end |
#hour(d = 0) ⇒ Numeric
時
973 974 975 |
# File 'lib/when_exe/inspect.rb', line 973 def hour(d=0) @clk_time[HOUR+d] end |
#local_time(sdn = nil) ⇒ Numeric
内部時間(ローカル)
401 402 403 404 |
# File 'lib/when_exe/tmptypes.rb', line 401 def local_time(sdn=nil) raise NameError, "Temporal Reference System is not defined" unless @frame @local_time ||= @frame.to_local_time(@clk_time, sdn) end |
#minute(d = 0) ⇒ Numeric Also known as: min
分
984 985 986 |
# File 'lib/when_exe/inspect.rb', line 984 def minute(d=0) @clk_time[MINUTE+d] end |
#name(index, format = nil) ⇒ When::BasicTypes::M17n
要素の多言語対応文字列化
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
# File 'lib/when_exe/inspect.rb', line 922 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
秒
996 997 998 |
# File 'lib/when_exe/inspect.rb', line 996 def second(d=0) @clk_time[SECOND+d] end |
#to_m17n(precision = @precision) ⇒ When::BasicTypes::M17n
多言語対応文字列化 - When.exe Standard Representation により多言語対応文字列化する
945 946 947 948 949 950 951 |
# File 'lib/when_exe/inspect.rb', line 945 def to_m17n(precision=@precision) time = m17n('T' + _time_to_s(precision)) if @frame time += @frame.zone unless Clock.is_local_time_set? && @frame.equal?(Clock.local_time) end return time end |
#to_s(precision = @precision) ⇒ String
文字列化 - When.exe Standard Representation により文字列化する
959 960 961 962 963 964 965 |
# File 'lib/when_exe/inspect.rb', line 959 def to_s(precision=@precision) time = 'T' + _time_to_s(precision) if @frame time += @frame.zone unless Clock.is_local_time_set? && @frame.equal?(Clock.local_time) end return time end |
#universal_time(sdn = nil) ⇒ Numeric
内部時間
386 387 388 389 |
# File 'lib/when_exe/tmptypes.rb', line 386 def universal_time(sdn=nil) raise NameError, "Temporal Reference System is not defined" unless @frame @universal_time ||= @frame.to_universal_time(@clk_time, sdn) end |