Class: When::TM::DateAndTime
- Inherits:
-
CalDate
- Object
- TemporalPosition
- CalDate
- When::TM::DateAndTime
- Defined in:
- lib/when_exe/tmposition.rb,
lib/when_exe/inspect.rb
Overview
時刻を伴った日付
see gml schema
Constant Summary
Constants inherited from CalDate
Constants inherited from TemporalPosition
TemporalPosition::AMPM, TemporalPosition::DateTimeInstanceMethods, TemporalPosition::Format, TemporalPosition::HashProperty
Constants included from Coordinates
Coordinates::Bahai, 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::Tibetan, Coordinates::VALUE, Coordinates::Yi
Constants included from When
CENTURY, 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
Constants included from Parts::Resource
Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty
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 ⇒ When::TM::ClockTime
(also: #clkTime)
readonly
時刻要素.
Attributes inherited from CalDate
#cal_date, #calendar_era, #calendar_era_name
Attributes inherited from TemporalPosition
#events, #frame, #indeterminated_position, #options, #precision, #query, #trans
Attributes included from Parts::Resource
#_pool, #child, #keys, #locale, #namespace
Instance Method Summary collapse
-
#&(other) ⇒ When::TM::DateAndTime
ユリウス日または通年が指定の剰余となる日.
-
#_attr ⇒ Object
属性の Hash.
-
#_copy(options = {}) ⇒ Object
属性のコピー.
-
#ceil(digit = DAY, precision = digit) ⇒ When::TM::DateAndTime
下位桁の切り上げ.
-
#clock ⇒ When::TM::Clock
時法の取得.
-
#floor(digit = DAY, precision = digit) ⇒ When::TM::DateAndTime
下位桁の切り捨て.
-
#hour(d = 0) ⇒ Numeric
時.
-
#initialize(date, time, options = {}) ⇒ DateAndTime
constructor
オブジェクトの生成.
-
#local_time ⇒ Numeric
内部時間(ローカル).
-
#location ⇒ When::Coordinates::Spatial
位置情報.
-
#minute(d = 0) ⇒ Numeric
(also: #min)
分.
-
#name(index, format = nil) ⇒ When::BasicTypes::M17n
要素の多言語対応文字列化.
-
#second(d = 0) ⇒ Numeric
(also: #sec)
秒.
-
#to_cal_date ⇒ When::TM::CalDate
(also: #to_CalDate)
時刻情報のない When::TM::CalDate を返す.
-
#to_m17n(precision = @precision, round = false) ⇒ When::BasicTypes::M17n
多言語対応文字列化 - When.exe Standard Representation により多言語対応文字列化する.
-
#to_s(precision = @precision, round = false) ⇒ String
文字列化 -When.exe Standard Representation により文字列化する.
-
#universal_time ⇒ Numeric
内部時間.
-
#value(index) ⇒ Numeric
要素の参照.
Methods inherited from CalDate
#%, #_event_form, #_to_h, #calendar_name, #cwday, #cweek, #cwyear, #day, #leaf?, #least_significant_coordinate, #length, #mday, #month, #most_significant_coordinate, #mweek, #reference_label, #to_i, #to_residue, #wday, #yday, #year, #ymon, #yweek
Methods inherited from TemporalPosition
#+, #+@, #-, #<=>, #==, #[], #^, _instance, #_notes, _options, _setup_, _setup_info, _temporal_position, #_term, #_to_h, #_to_s, _verify, #calendar_name, #caret_frame, #clock_name, #copy, #dynamical_time, format, #has_next?, #has_time?, #include?, #inspect, #is?, #month_included, #note?, #notes, #period, #prev, #rate_of_clock, #reference_label, #scan, #strftime, #succ, #time_standard, #to_clock_time, #to_date, #to_datetime, #to_f, #to_i, #to_residue, #to_time, #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, _define_common_calendar_types, _setup_, _setup_info, at, client, column, config, const_missing, era, free_conv, m17n, now, server, today, when?
Methods included from TemporalPosition::Conversion
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
Constructor Details
#initialize(date, time, options = {}) ⇒ DateAndTime
オブジェクトの生成
2172 2173 2174 2175 |
# File 'lib/when_exe/tmposition.rb', line 2172 def initialize(date, time, ={}) [:time] = time super(date, ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class When::TM::TemporalPosition
Instance Attribute Details
#clk_time ⇒ When::TM::ClockTime (readonly) Also known as: clkTime
時刻要素
1982 1983 1984 |
# File 'lib/when_exe/tmposition.rb', line 1982 def clk_time @clk_time end |
Instance Method Details
#&(other) ⇒ When::TM::DateAndTime
ユリウス日または通年が指定の剰余となる日
2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 |
# File 'lib/when_exe/tmposition.rb', line 2038 def &(other) raise TypeError,"The right operand should be When::Coordinates::Residue" unless other.kind_of?(Residue) case other.event when 'day' # 指定の剰余となる日 sdn = other & to_i = {:date=>_date_with_era(@frame.to_cal_date(sdn)), :time=>@clk_time.clk_time.dup, :events=>nil, :query=>@query, :validate=>:done} [:precision] = When::DAY if precision < When::DAY result = self.dup._copy() result.send(:_force_euqal_day, sdn-result.to_i) when 'year' # 指定の剰余となる年 date = @frame.send(:_decode, _date_without_era) date[0] = (other & (date[0] + @frame.diff_to_CE)) - @frame.diff_to_CE = {:date=>_date_with_era(@frame.send(:_encode, date)), :time=>@clk_time.clk_time.dup, :events=>nil, :query=>@query} [:precision] = When::YEAR if precision < When::YEAR return self.dup._copy() else raise ArgumentError,"The right operand should have a unit 'day' or 'year'" end end |
#_attr ⇒ Object
属性の Hash
2137 2138 2139 |
# File 'lib/when_exe/tmposition.rb', line 2137 def _attr super.merge({:clock=>clock}) end |
#_copy(options = {}) ⇒ Object
属性のコピー
2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 |
# File 'lib/when_exe/tmposition.rb', line 2143 def _copy(={}) # 夏時間の調整 case [:time] when Array if clock._need_validate new_clock = clock._daylight([@frame, [:date], [:time]]) [:time] = [:time].map {|t| t * 1} else new_clock = clock end [:time] = @clk_time.dup._copy(.merge({:clock=>new_clock})) when nil [:time] = @clk_time.dup._copy() end return super() end |
#ceil(digit = DAY, precision = digit) ⇒ When::TM::DateAndTime
下位桁の切り上げ
2100 2101 2102 2103 2104 2105 2106 2107 |
# File 'lib/when_exe/tmposition.rb', line 2100 def ceil(digit=DAY, precision=digit) length = clock.indices.length count = digit - length period = PeriodDuration.new((count<=0) ? 1 : 0.1**count, digit, (-@frame.indices.length)..length) result = floor(digit, precision) + period result += clock.tz_difference if (result.universal_time <= self.universal_time) return result end |
#clock ⇒ When::TM::Clock
時法の取得
1989 1990 1991 |
# File 'lib/when_exe/tmposition.rb', line 1989 def clock @clk_time.frame end |
#floor(digit = DAY, precision = digit) ⇒ When::TM::DateAndTime
下位桁の切り捨て
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 |
# File 'lib/when_exe/tmposition.rb', line 2072 def floor(digit=DAY, precision=digit) count = digit - clock.indices.length date = (digit>=DAY) ? @cal_date.dup : @frame._validate(@cal_date[0..(digit-1)]) time = @clk_time.clk_time[0..((digit<=DAY) ? 0 : ((count>=0) ? -1 : digit))] time[0] += to_i time = clock._validate(time) time[0] -= to_i if (count >= 0) factor = 10**count time[-1] = (time[-1] * factor).floor.to_f / factor end # オブジェクトの生成 = {:date=>date, :validate=>:done, :events=>nil, :query=>nil, :time=>(digit<=DAY) ? time : @clk_time.dup._copy({:time=>time})} [:precision] = precision if precision return self.dup._copy() end |
#hour(d = 0) ⇒ Numeric
時
1381 1382 1383 |
# File 'lib/when_exe/inspect.rb', line 1381 def hour(d=0) @clk_time.hour(d) end |
#local_time ⇒ Numeric
内部時間(ローカル)
2015 2016 2017 2018 2019 |
# File 'lib/when_exe/tmposition.rb', line 2015 def local_time return super if [Now, Max, Min].include?(@indeterminated_position) raise NameError, "Temporal Reference System is not defined" unless (@frame && clock) @local_time ||= (to_i - JulianDate::JD19700101) * Duration::DAY + @clk_time.local_time(to_i) end |
#location ⇒ When::Coordinates::Spatial
位置情報
2113 2114 2115 |
# File 'lib/when_exe/tmposition.rb', line 2113 def location @location ||= @clk_time.frame.location end |
#minute(d = 0) ⇒ Numeric Also known as: min
分
1391 1392 1393 |
# File 'lib/when_exe/inspect.rb', line 1391 def minute(d=0) @clk_time.minute(d) end |
#name(index, format = nil) ⇒ When::BasicTypes::M17n
要素の多言語対応文字列化
1337 1338 1339 1340 |
# File 'lib/when_exe/inspect.rb', line 1337 def name(index, format=nil) digit = _digit(index) (digit <= DAY) ? super : @clk_time.name(digit, format) end |
#second(d = 0) ⇒ Numeric Also known as: sec
秒
1402 1403 1404 |
# File 'lib/when_exe/inspect.rb', line 1402 def second(d=0) @clk_time.second(d) end |
#to_cal_date ⇒ When::TM::CalDate Also known as: to_CalDate
時刻情報のない When::TM::CalDate を返す
2121 2122 2123 2124 2125 2126 |
# File 'lib/when_exe/tmposition.rb', line 2121 def to_cal_date = _attr .delete(:clock) [:precision] = [When::DAY, [:precision]].min CalDate.new(@cal_date, ) end |
#to_m17n(precision = @precision, round = false) ⇒ When::BasicTypes::M17n
丸めるのは precision が When::DAY よりも高精度の場合のみである
多言語対応文字列化 - When.exe Standard Representation により多言語対応文字列化する
1350 1351 1352 |
# File 'lib/when_exe/inspect.rb', line 1350 def to_m17n(precision=@precision, round=false) super + _clk_time_for_inspect(round ? precision : nil).to_m17n(precision) end |
#to_s(precision = @precision, round = false) ⇒ String
丸めるのは precision が When::DAY よりも高精度の場合のみである
文字列化 -When.exe Standard Representation により文字列化する
1362 1363 1364 |
# File 'lib/when_exe/inspect.rb', line 1362 def to_s(precision=@precision, round=false) super + _clk_time_for_inspect(round ? precision : nil).to_s(precision) end |
#universal_time ⇒ Numeric
内部時間
2001 2002 2003 2004 2005 |
# File 'lib/when_exe/tmposition.rb', line 2001 def universal_time return super if [Now, Max, Min].include?(@indeterminated_position) raise NameError, "Temporal Reference System is not defined" unless (@frame && clock) @universal_time ||= (to_i - JulianDate::JD19700101) * Duration::DAY + @clk_time.universal_time(to_i) end |