Class: When::TM::CalDate
- Inherits:
-
TemporalPosition
- Object
- TemporalPosition
- When::TM::CalDate
- Defined in:
- lib/when_exe/tmptypes.rb,
lib/when_exe/linkeddata.rb,
lib/when_exe/inspect.rb
Overview
When::TM::CalDate への追加
Direct Known Subclasses
Constant Summary collapse
Constants inherited from TemporalPosition
TemporalPosition::AMPM, TemporalPosition::DateTimeInstanceMethods, TemporalPosition::Format, TemporalPosition::HashProperty
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 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
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
-
#cal_date ⇒ Array<Numeric>
(also: #calDate)
readonly
日付要素.
-
#calendar_era ⇒ When::TM::CalendarEra
(also: #calendarEra)
readonly
暦年代.
-
#calendar_era_props ⇒ Array
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
-
#%(other) ⇒ Numeric
ユリウス日または通年の剰余.
-
#&(other) ⇒ When::TM::CalDate
ユリウス日または通年が指定の剰余となる日.
-
#_attr ⇒ Object
属性の Hash.
-
#_event_form(other = nil, options = {}) ⇒ String
event を 文字列化 - 日時で与えられた event を文字列化する.
-
#_to_h(options = {}) ⇒ Hash
Hash 化.
-
#calendar_era_epoch ⇒ Integer
暦年代元期.
-
#calendar_era_go_back ⇒ Boolean
暦年代遡及.
-
#calendar_era_name ⇒ String
(also: #calendarEraName)
暦年代名.
-
#calendar_era_reverse ⇒ Boolean
暦年代正逆.
-
#calendar_name ⇒ Array
暦法名.
-
#ceil(digit = DAY, precision = digit) ⇒ When::TM::CalDate
下位桁の切り上げ.
-
#clock ⇒ Object
時法の取得 - ダミー.
-
#coordinate ⇒ Numeric
時間座標値.
-
#cwday ⇒ Numeric
七曜(暦週).
-
#cweek(d = 0) ⇒ Numeric
暦週.
-
#cwyear(d = 0) ⇒ Numeric
暦週の年.
-
#day(d = 0) ⇒ Numeric
日.
-
#floor(digit = DAY, precision = digit) ⇒ When::TM::CalDate
下位桁の切り捨て.
-
#leaf? ⇒ Boolean
暦年代が末端の参照であるか?.
-
#least_significant_coordinate ⇒ Numeric
最下位の要素.
-
#length(upper, lower = DAY) ⇒ Integer
要素数 ― 上位要素に含まれる下位要素の数.
-
#mday(d = 0) ⇒ Numeric
月内通日.
-
#member ⇒ Array<When::TM::CalDate>
自身に所属する When::TM::CalDate オブジェクト.
-
#month(d = 0) ⇒ Numeric
(also: #mon)
月.
-
#most_significant_coordinate ⇒ Numeric
最上位の要素.
-
#mweek(w = 6, m = 7, d = 0) ⇒ Numeric
月内通週.
-
#name(index, format = nil) ⇒ When::BasicTypes::M17n
要素の多言語対応文字列化.
-
#prev ⇒ When::TM::TemporalPosition
前の日時.
-
#rdf_graph(options = {}) ⇒ Hash
自身を root とするグラフの jsonld を表現する Hash を生成する.
-
#reference_label(format = nil, locale = nil) ⇒ When::BasicTypes::M17n
参照ラベル.
-
#register_graph(graph, options = {}) ⇒ Array
CalDateオブジェクトの jsonld をグラフに追加する.
-
#succ ⇒ When::TM::TemporalPosition
(also: #next)
次の日時.
-
#to_i ⇒ Integer
ユリウス日.
-
#to_jsonld_hash(options = {}) ⇒ Hash
CalDateオブジェクトの jsonld を表現する Hash を生成する.
-
#to_linked_data(writer = :jsonld, options = {}) ⇒ String
自身を root とするグラフの jsonld を表現する Hash を各種のRDF表現形式に変換する.
-
#to_m17n(precision = @precision, round = false) ⇒ When::BasicTypes::M17n
多言語対応文字列化 - When.exe Standard Representation により多言語対応文字列化する.
-
#to_residue(remainder, divisor) ⇒ When::Coordinates::Residue
剰余類化.
-
#to_s(precision = @precision, round = false) ⇒ String
文字列化 - When.exe Standard Representation により文字列化する.
-
#to_uri_linkeddata ⇒ String
URI - linked data 用.
-
#universal_time ⇒ Numeric
(also: #local_time)
内部時間.
-
#value(index) ⇒ Numeric
要素の参照.
-
#wday ⇒ Numeric
七曜.
-
#without_era ⇒ When::TM::CalDate
暦年代の削除.
-
#yday(d = 0) ⇒ Numeric
年内通日.
-
#year(d = 0) ⇒ Numeric
年.
-
#ymon(d1 = 0, d2 = 0) ⇒ Numeric
年内通月.
-
#yweek(w = 6, m = 7, d = 0) ⇒ Numeric
年内通週.
Methods inherited from TemporalPosition
#+, #+@, #-, #<=>, #==, #[], #^, _instance, _instance_element, #_notes, _options, _setup_, _setup_info, _temporal_position, #_to_s, _verify, #apply_delayed_options, #clock_name, #copy, #dynamical_time, format, #has_next?, #has_time?, #include?, #inspect, #is?, #month_included, #note?, #notes, #period, #rate_of_clock, #scan, #strftime, #time_standard, #to_clock_time, #to_date, #to_datetime, #to_f, #to_time, #to_uri, #to_uri_escape, #week_included, #year_included
Methods included from Coordinates
to_deg, to_deg_225, to_dms, utf_gets
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, date_or_era, era, free_conv, m17n, now, server, strptime, today, when?, where?
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, #m17n, #map, #parent, #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::TM::TemporalPosition
Instance Attribute Details
#cal_date ⇒ Array<Numeric> (readonly) Also known as: calDate
ISO19108 では sequence<Integer> だが、閏月などが表現可能なよう Numeric としている。
日付要素
504 505 506 |
# File 'lib/when_exe/tmptypes.rb', line 504 def cal_date @cal_date end |
#calendar_era ⇒ When::TM::CalendarEra Also known as: calendarEra
暦年代
519 520 521 |
# File 'lib/when_exe/tmptypes.rb', line 519 def calendar_era @calendar_era end |
#calendar_era_props ⇒ Array
暦年代属性
531 532 533 |
# File 'lib/when_exe/tmptypes.rb', line 531 def calendar_era_props @calendar_era_props end |
Instance Method Details
#%(other) ⇒ Numeric
ユリウス日または通年の剰余
730 731 732 733 734 735 736 737 738 739 740 741 |
# File 'lib/when_exe/tmptypes.rb', line 730 def %(other) raise TypeError,"The right operand should be When::Coordinates::Residue" unless other.kind_of?(Residue) if precision <= When::YEAR && other.units['year'] && other.event != 'year' other.to('year') % (most_significant_coordinate + @frame.epoch_in_CE) else case other.event when 'day' ; other % least_significant_coordinate when 'year' ; other % (most_significant_coordinate + @frame.epoch_in_CE) else ; raise ArgumentError,"The right operand should have a unit 'day' or 'year'" end end end |
#&(other) ⇒ When::TM::CalDate
ユリウス日または通年が指定の剰余となる日
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 |
# File 'lib/when_exe/tmptypes.rb', line 700 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)), :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)), :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
799 800 801 |
# File 'lib/when_exe/tmptypes.rb', line 799 def _attr super.merge({:era_name=>@calendar_era_props, :era=>@calendar_era}) end |
#_event_form(other = nil, options = {}) ⇒ String
events 配列なし - 日時をそのまま文字列化 日時の精度が日より細かい - イベント名(イベント時刻) 日時の精度が日 - イベント名(当日までの経過日数)
event を 文字列化 - 日時で与えられた event を文字列化する
1344 1345 1346 1347 1348 1349 1350 1351 1352 |
# File 'lib/when_exe/inspect.rb', line 1344 def _event_form(other=nil, ={}) return [:method]==:to_m17n ? to_m17n : self unless events return events[0] + '(' + _clk_time_for_inspect([:precision]). to_s([:precision] || precision)[/[:*=0-9]+/] + ')' if precision > When::DAY return events[0] unless other other = JulianDate.dynamical_time(other.dynamical_time, {:time_standard=>time_standard}) unless time_standard.rate_of_clock == other.time_standard.rate_of_clock events[0] + '(' + (other.to_i - to_i).to_s + ')' end |
#_to_h(options = {}) ⇒ Hash
Hash 化
1136 1137 1138 |
# File 'lib/when_exe/inspect.rb', line 1136 def _to_h(={}) super.update({:cal_date=>@cal_date}) end |
#calendar_era_epoch ⇒ Integer
暦年代元期
547 548 549 |
# File 'lib/when_exe/tmptypes.rb', line 547 def calendar_era_epoch @calendar_era_props ? @calendar_era_props[1] : 0 end |
#calendar_era_go_back ⇒ Boolean
暦年代遡及
563 564 565 |
# File 'lib/when_exe/tmptypes.rb', line 563 def calendar_era_go_back @calendar_era_props ? @calendar_era_props[3] : false end |
#calendar_era_name ⇒ String Also known as: calendarEraName
暦年代名
538 539 540 |
# File 'lib/when_exe/tmptypes.rb', line 538 def calendar_era_name @calendar_era_props ? @calendar_era_props[0] : nil end |
#calendar_era_reverse ⇒ Boolean
暦年代正逆
555 556 557 |
# File 'lib/when_exe/tmptypes.rb', line 555 def calendar_era_reverse @calendar_era_props ? @calendar_era_props[2] : false end |
#calendar_name ⇒ Array
暦法名
1061 1062 1063 1064 1065 1066 |
# File 'lib/when_exe/inspect.rb', line 1061 def calendar_name void, epoch, reverse, back = @calendar_era_props name = [@calendar_era || @frame, epoch, reverse, back] name.pop until name[-1] return name end |
#ceil(digit = DAY, precision = digit) ⇒ When::TM::CalDate
下位桁の切り上げ
765 766 767 |
# File 'lib/when_exe/tmptypes.rb', line 765 def ceil(digit=DAY, precision=digit) (self + PeriodDuration.new(1, digit, (-@frame.indices.length)..0)).floor(digit, precision) end |
#clock ⇒ Object
時法の取得 - ダミー
568 569 570 |
# File 'lib/when_exe/tmptypes.rb', line 568 def clock nil end |
#coordinate ⇒ Numeric
時間座標値
1087 1088 1089 1090 |
# File 'lib/when_exe/inspect.rb', line 1087 def coordinate raise ArgumentError, "Presicion not defined" unless When::Coordinates::PERIOD_NAME[@precision] self[@precision] end |
#cwday ⇒ Numeric
七曜(暦週)
1206 1207 1208 |
# File 'lib/when_exe/inspect.rb', line 1206 def cwday (to_i % 7) + 1 end |
#cweek(d = 0) ⇒ Numeric
暦週
1216 1217 1218 1219 1220 1221 1222 |
# File 'lib/when_exe/inspect.rb', line 1216 def cweek(d=0) [1,0,-1].each do |i| start = ((self + PeriodDuration.new(i, YEAR-d)).floor(YEAR-d,DAY) + PeriodDuration.new(4, DAY)) & Residue.new(0,7,-1) return ((to_i - start.to_i).div 7) + 1 if self >= start end raise IndexError, 'Cannot decide year number' end |
#cwyear(d = 0) ⇒ Numeric
暦週の年
1292 1293 1294 1295 1296 1297 1298 |
# File 'lib/when_exe/inspect.rb', line 1292 def cwyear(d=0) [1,0,-1].each do |i| start = ((self + PeriodDuration.new(i, YEAR-d)).floor(YEAR-d,DAY) + PeriodDuration.new(4, DAY)) & Residue.new(0,7,-1) return year(d)+i if self >= start end raise IndexError, 'Cannot decide year number' end |
#day(d = 0) ⇒ Numeric
日
1170 1171 1172 |
# File 'lib/when_exe/inspect.rb', line 1170 def day(d=0) @cal_date[DAY-1-d] end |
#floor(digit = DAY, precision = digit) ⇒ When::TM::CalDate
下位桁の切り捨て
751 752 753 754 755 |
# File 'lib/when_exe/tmptypes.rb', line 751 def floor(digit=DAY, precision=digit) = {:date=>@cal_date[0..(digit-1)], :events=>nil, :query=>nil} [:precision] = precision if precision self.dup._copy() end |
#leaf? ⇒ Boolean
暦年代が末端の参照であるか?
793 794 795 |
# File 'lib/when_exe/tmptypes.rb', line 793 def leaf? ! @calendar_era.respond_to?(:_pool) || @calendar_era.leaf? end |
#least_significant_coordinate ⇒ Numeric
最下位の要素
690 691 692 |
# File 'lib/when_exe/tmptypes.rb', line 690 def least_significant_coordinate return to_i + @frame.indices[-1].shift end |
#length(upper, lower = DAY) ⇒ Integer
要素数 ― 上位要素に含まれる下位要素の数
776 777 778 779 780 |
# File 'lib/when_exe/tmptypes.rb', line 776 def length(upper, lower=DAY) range = [floor(upper).to_i, ceil(upper).to_i] range = range.map {|d| (Residue.mod(d) {|m| frame._new_month(m)})[0]} if lower == MONTH range[1] - range[0] end |
#mday(d = 0) ⇒ Numeric
月内通日
1180 1181 1182 |
# File 'lib/when_exe/inspect.rb', line 1180 def mday(d=0) to_i - floor(MONTH-d).to_i + 1 end |
#member ⇒ Array<When::TM::CalDate>
precision が 0(When::DAY) の場合、空 Array を返す
自身に所属する When::TM::CalDate オブジェクト
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 |
# File 'lib/when_exe/inspect.rb', line 1099 def member raise ArgumentError, "Presicion not defined" unless When::Coordinates::PERIOD_NAME[@precision] child = floor(@precision+1) list = [] while self == child list << child child = child.succ end list end |
#month(d = 0) ⇒ Numeric Also known as: mon
月
1255 1256 1257 |
# File 'lib/when_exe/inspect.rb', line 1255 def month(d=0) @cal_date[MONTH-1-d] end |
#most_significant_coordinate ⇒ Numeric
最上位の要素
676 677 678 679 680 681 682 683 |
# File 'lib/when_exe/tmptypes.rb', line 676 def most_significant_coordinate coordinate = @cal_date[0] coordinate += calendar_era_epoch if @calendar_era_props @frame.index_of_MSC.times do |i| coordinate = +coordinate * @frame.indices[i].unit + @cal_date[i+1] - @frame.indices[i].base end coordinate end |
#mweek(w = 6, m = 7, d = 0) ⇒ Numeric
月内通週
1232 1233 1234 |
# File 'lib/when_exe/inspect.rb', line 1232 def mweek(w=6, m=7, d=0) 1 + (to_i - (floor(MONTH-d,DAY) & Residue.new(w,m)).to_i).div(7) end |
#name(index, format = nil) ⇒ When::BasicTypes::M17n
要素の多言語対応文字列化
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
# File 'lib/when_exe/inspect.rb', line 1147 def name(index, format=nil) digit = _digit(index) {|digit| digit <= DAY} coordinate = @cal_date[digit-1] 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||0]) end |
#prev ⇒ When::TM::TemporalPosition
前の日時
615 616 617 618 619 |
# File 'lib/when_exe/tmptypes.rb', line 615 def prev @precision==When::DAY ? _force_euqal_day(-1) : self-period rescue RangeError (When::Gregorian ^ self) - period end |
#rdf_graph(options = {}) ⇒ Hash
自身を root とするグラフの jsonld を表現する Hash を生成する
500 501 502 503 |
# File 'lib/when_exe/linkeddata.rb', line 500 def rdf_graph(={}) root = [:include] && precision < When::YEAR ? floor(When::YEAR) : self When::Parts::Resource.rdf_graph([root], ) end |
#reference_label(format = nil, locale = nil) ⇒ When::BasicTypes::M17n
参照ラベル
1076 1077 1078 1079 1080 |
# File 'lib/when_exe/inspect.rb', line 1076 def reference_label(format=nil, locale=nil) return @calendar_era.hierarchy.map {|e| format ? e.suffixed_label(format, locale) : e.label} if @calendar_era return [format ? @frame.suffixed_label(format, locale) : @frame.label] if @frame.label [When::BasicTypes::M17n.new(@frame.class.to_s.split(/::/)[-1])] end |
#register_graph(graph, options = {}) ⇒ Array
CalDateオブジェクトの jsonld をグラフに追加する
515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/when_exe/linkeddata.rb', line 515 def register_graph(graph, ={}) jsonld_hash = to_jsonld_hash() graph << jsonld_hash if [:include] && precision < When::DAY included = floor(precision+1) included_opt = {:included=>jsonld_hash['@id']}.update() while include?(included) do included.register_graph(graph, included_opt) included = included.succ end end end |
#succ ⇒ When::TM::TemporalPosition Also known as: next
次の日時
627 628 629 630 631 |
# File 'lib/when_exe/tmptypes.rb', line 627 def succ @precision==When::DAY ? _force_euqal_day(+1) : self+period rescue RangeError (When::Gregorian ^ self) + period end |
#to_i ⇒ Integer
ユリウス日
590 591 592 |
# File 'lib/when_exe/tmptypes.rb', line 590 def to_i @sdn ||= _to_i end |
#to_jsonld_hash(options = {}) ⇒ Hash
:prev,:succ,:included が true のときは自身で当該IRIを計算する。 nil,false のときは当該情報を戻り値のHashに追加しない。
CalDateオブジェクトの jsonld を表現する Hash を生成する
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
# File 'lib/when_exe/linkeddata.rb', line 544 def to_jsonld_hash(={}) hash, context, base = hash_and_variables() tp = base + 'tp/' ts = base + 'ts#' hash['@id'] ||= tp + to_uri_escape hash[ts + 'sdn'] = precision <= When::DAY ? to_i : to_f hash[ts + 'frame'] = {'@id'=>frame.iri(false)} hash[ts + 'calendarEra'] = {'@id'=>calendar_era.iri(false)} if calendar_era hash[ts + 'coordinate'] = self[precision].to_s hash[ts + 'ruler'] = {'@id'=>query['name'].iri} if query && query['name'].kind_of?(When::BasicTypes::M17n) hash[ts + 'succ'] = [:succ].kind_of?(String) ? [:succ] : {'@id'=>tp + succ.to_uri_escape} if [:succ] hash[ts + 'prev'] = [:prev].kind_of?(String) ? [:prev] : {'@id'=>tp + prev.to_uri_escape} if [:prev] hash['@reverse'] = (hash['@reverse'] || {}).merge( {RDFS + 'member'=> {'@id'=>[:included].kind_of?(String) ? [:included] : tp + floor(precision-1).to_uri_escape } }) if [:included] && precision + frame.indices.size > 0 compact_predicate(hash, context, [:prefixes]) = {:indices=>precision, :notes=>:all} .update([:note]) if [:note] notes().first.each do |note| next unless note[:note] if note[:value].kind_of?(Array) value = note[:value].flatten.reject {|v| v.kind_of?(Hash) || v =~ /-\z/ }.map {|v| _value_str(note[:note], v)} value = value.first if value.size == 1 else value =_value_str(note[:note], note[:value]) end id = compact_namespace_to_prefix(value, [:prefixes], context) hash[compact_namespace_to_prefix(_note_str(note[:note]), [:prefixes], context)] = (id == value && id !~ /:\/\//) ? id : {'@id'=>id} end hash end |
#to_linked_data(writer = :jsonld, options = {}) ⇒ String
自身を root とするグラフの jsonld を表現する Hash を各種のRDF表現形式に変換する
486 487 488 489 |
# File 'lib/when_exe/linkeddata.rb', line 486 def to_linked_data(writer=:jsonld, ={}) hash = rdf_graph({:include=>true}.update()) When::Parts::Resource.to_linked_data(hash, writer, hash['@context']) end |
#to_m17n(precision = @precision, round = false) ⇒ When::BasicTypes::M17n
多言語対応文字列化 - When.exe Standard Representation により多言語対応文字列化する
1307 1308 1309 1310 1311 1312 1313 |
# File 'lib/when_exe/inspect.rb', line 1307 def to_m17n(precision=@precision, round=false) date = m17n(_date_to_s(precision)) return date unless @calendar_era return _parent_labels.inject(m17n(calendar_era_name)) {|era_name, parent| era_name.prefix(m17n(parent) + '::') } + date end |
#to_residue(remainder, divisor) ⇒ When::Coordinates::Residue
剰余類化
641 642 643 644 |
# File 'lib/when_exe/tmptypes.rb', line 641 def to_residue(remainder, divisor) When::Coordinates::Residue.new(remainder, divisor, {'day' => least_significant_coordinate, 'year' => most_significant_coordinate}) end |
#to_s(precision = @precision, round = false) ⇒ String
文字列化 - When.exe Standard Representation により文字列化する
1322 1323 1324 1325 1326 1327 1328 |
# File 'lib/when_exe/inspect.rb', line 1322 def to_s(precision=@precision, round=false) date = _date_to_s(precision) return date unless @calendar_era return _parent_labels.inject(calendar_era_name.to_s) {|era_name, parent| parent.to_s + '::' + era_name } + date end |
#to_uri_linkeddata ⇒ String
URI - linked data 用
471 472 473 474 475 476 |
# File 'lib/when_exe/linkeddata.rb', line 471 def to_uri_linkeddata(*args) date, frame = _to_uri(to_s(*args)).split('^^', 2) frame += '_' if /\d\z/ =~ frame date = "#{frame}(#{date})" if frame When::Parts::Resource.base_uri.sub(/When\/$/, 'tp/') + date end |
#universal_time ⇒ Numeric Also known as: local_time
内部時間
578 579 580 581 |
# File 'lib/when_exe/tmptypes.rb', line 578 def universal_time return super if [Now, Max, Min].include?(@indeterminated_position) @universal_time ||= JulianDate._d_to_t(to_i) end |
#value(index) ⇒ Numeric
要素の参照
667 668 669 |
# File 'lib/when_exe/tmptypes.rb', line 667 def value(index) @cal_date[(_digit(index) {|digit| digit <= DAY})-1] end |
#wday ⇒ Numeric
七曜
1198 1199 1200 |
# File 'lib/when_exe/inspect.rb', line 1198 def wday (to_i + 1) % 7 end |
#without_era ⇒ When::TM::CalDate
暦年代の削除
650 651 652 653 654 655 656 657 658 659 |
# File 'lib/when_exe/tmptypes.rb', line 650 def without_era target = dup return target unless calendar_era = _attr [:era] = nil [:era_name] = nil [:date] = cal_date.dup [:date][0] += calendar_era_epoch target._copy() end |
#yday(d = 0) ⇒ Numeric
年内通日
1190 1191 1192 |
# File 'lib/when_exe/inspect.rb', line 1190 def yday(d=0) to_i - floor(YEAR-d).to_i + 1 end |
#year(d = 0) ⇒ Numeric
年
1282 1283 1284 |
# File 'lib/when_exe/inspect.rb', line 1282 def year(d=0) @cal_date[YEAR-1-d] end |
#ymon(d1 = 0, d2 = 0) ⇒ Numeric
年内通月
1267 1268 1269 1270 1271 1272 1273 1274 |
# File 'lib/when_exe/inspect.rb', line 1267 def ymon(d1=0, d2=0) current = floor(YEAR-d1, MONTH-d2) @frame._length(@cal_date[(YEAR-1-d1)...(MONTH-1-d2)]).times do |i| return i+1 if current == self current = current.succ end raise IndexError, 'Cannot decide month number' end |