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::Format, TemporalPosition::HashProperty
Constants included from Coordinates
Coordinates::Bahai, Coordinates::CommonResidue, Coordinates::DefaultDateIndices, Coordinates::DefaultDayIndex, Coordinates::DefaultTimeIndices, Coordinates::IndianCities, 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, DurationP1D, DurationP1M, DurationP1W, DurationP1Y, EUCJP, HOUR, MINUTE, MONTH, MinusInfinity, PlusInfinity, RootDir, SECOND, STRING, SYSTEM, SourceURI, When::TimeValue, UTF8, VERSION, W31J, WEEK, YEAR
Constants included from Parts::Resource
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
オブジェクトの生成.
-
#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, #_term, #_to_h, #_to_s, _verify, #calendar_name, #caret_frame, #clock_name, #copy, #dynamical_time, format, #has_next?, #has_time?, #include?, #is?, #month_included, #note?, #notes, #period, #prev, #rate_of_clock, #reference_label, #scan, #strftime, #succ, #time_standard, #to_clock_time, #to_date, #to_date_time, #to_f, #to_i, #to_residue, #to_time, #week_included, #year_included
Methods included from Coordinates
Methods included from When
Calendar, CalendarEra, CalendarNote, Clock, Duration, Location, M17n, MonthName, Pair, Residue, Resource, TemporalPosition, Wikipedia, _setup_, _setup_info, at, client, config, era, free_conv, m17n, now, server, today, utc, when?
Methods included from TemporalPosition::Conversion
Methods included from Parts::Resource
#[], #^, _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
オブジェクトの生成
1970 1971 1972 1973 |
# File 'lib/when_exe/tmposition.rb', line 1970 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
時刻要素
1800 1801 1802 |
# File 'lib/when_exe/tmposition.rb', line 1800 def clk_time @clk_time end |
Instance Method Details
#&(other) ⇒ When::TM::DateAndTime
ユリウス日または通年が指定の剰余となる日
1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 |
# File 'lib/when_exe/tmposition.rb', line 1843 def &(other) raise TypeError,"The right operand should be When::Coordinates::Residue" unless other.kind_of?(Residue) case other.event when 'day' # 指定の剰余となる日 other -= @frame.indices[-1].shift unless @frame.indices[-1].shift == 0 return self.dup._copy({:events=>nil, :query=>@query, :validate=>:done, :date=>_date_with_era(@frame.to_cal_date(other & to_i)), :time=>@clk_time.clk_time.dup}) when 'year' # 指定の剰余となる年 date = @cal_date.dup date[0] = (other & (most_significant_coordinate + @frame._diff_to_CE)) - @frame._diff_to_CE return self.dup._copy({:events=>nil, :query=>@query, :date=>_date_with_era(date), :time=>@clk_time.clk_time.dup}) else raise ArgumentError,"The right operand should have a unit 'day' or 'year'" end end |
#_attr ⇒ Object
属性の Hash
1935 1936 1937 |
# File 'lib/when_exe/tmposition.rb', line 1935 def _attr super.merge({:clock=>clock}) end |
#_copy(options = {}) ⇒ Object
属性のコピー
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 |
# File 'lib/when_exe/tmposition.rb', line 1941 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
下位桁の切り上げ
1899 1900 1901 1902 1903 1904 1905 1906 |
# File 'lib/when_exe/tmposition.rb', line 1899 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
時法の取得
1807 1808 1809 |
# File 'lib/when_exe/tmposition.rb', line 1807 def clock @clk_time.frame end |
#floor(digit = DAY, precision = digit) ⇒ When::TM::DateAndTime
下位桁の切り捨て
1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 |
# File 'lib/when_exe/tmposition.rb', line 1874 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 = clock._validate(@clk_time.clk_time[0..((digit<=DAY) ? 0 : ((count>=0) ? -1 : digit))]) 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
時
1288 1289 1290 |
# File 'lib/when_exe/inspect.rb', line 1288 def hour(d=0) @clk_time.hour(d) end |
#location ⇒ When::Coordinates::Spatial
位置情報
1912 1913 1914 1915 1916 1917 |
# File 'lib/when_exe/tmposition.rb', line 1912 def location return @location if @location timezone = @clk_time.frame.tz_prop return nil unless timezone.kind_of?(When::Parts::Timezone) @location = timezone.location end |
#minute(d = 0) ⇒ Numeric Also known as: min
分
1298 1299 1300 |
# File 'lib/when_exe/inspect.rb', line 1298 def minute(d=0) @clk_time.minute(d) end |
#name(index, format = nil) ⇒ When::BasicTypes::M17n
要素の多言語対応文字列化
1244 1245 1246 1247 |
# File 'lib/when_exe/inspect.rb', line 1244 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
秒
1309 1310 1311 |
# File 'lib/when_exe/inspect.rb', line 1309 def second(d=0) @clk_time.second(d) end |
#to_cal_date ⇒ When::TM::CalDate Also known as: to_CalDate
時刻情報のない When::TM::CalDate を返す
1923 1924 1925 1926 1927 1928 |
# File 'lib/when_exe/tmposition.rb', line 1923 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 により多言語対応文字列化する
1257 1258 1259 |
# File 'lib/when_exe/inspect.rb', line 1257 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 により文字列化する
1269 1270 1271 |
# File 'lib/when_exe/inspect.rb', line 1269 def to_s(precision=@precision, round=false) super + _clk_time_for_inspect(round ? precision : nil).to_s(precision) end |
#universal_time ⇒ Numeric
内部時間
1819 1820 1821 1822 1823 1824 |
# File 'lib/when_exe/tmposition.rb', line 1819 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 - +@clk_time.clk_time[0] - JulianDate::JD19700101) * Duration::DAY + @clk_time.universal_time end |