時計
see gml schema
地方時
type : When::TM::Clock or When::V::Timezone 本変数の write access はテスト用である。 本変数は、原則、ライブラリ立ち上げ時に setup で初期化する。 以降、本変数に代入を行っても、すでに生成した When::TM::TemporalPosition には反映されない。
この時法の基点となる事象
Event used as the datum for this clock
type : String new の options 引数に :reference_event があれば設定される。 ライブラリとしては本変数を参照していない。下記の振る舞いを String で説明するため用いてもよい。 日付の境界が午前0時でない場合、When::Coordinates::Temporal.epoch により、境界が指定される。 _epoch メソッドをオーバーライドすることで、日の出、日の入りなど event 時刻が一定しない場合 にも対応する。
この時法による参照事象の時刻
Time of the reference event for this clock
type : When::TM::ClockTime
一暦日の中の時間位置を定めるために、この時計とともに使用する暦 (relation - Resolution)
The calendar that is used with this clock to define temporal position within a calendar day
type : [When::TM::Calendar]
When::TM::Clock Class のグローバルな設定を行う
local : When::TM::Clock or When::V::Timezone
地方時を使用する場合、指定する
# File when/tmreference.rb, line 220
220: def setup(local=nil)
221: @_pool = {}
222: @local_time = local
223: end
When::TM::(Temporal)Position の時間帯を変更して複製する
date : When::TM::CalDate, When::TM::DateAndTime or When::TM::JulianDate options : see When::TM::TemporalPosition._instance returns : When::TM::DateAndTime or When::TM::JulianDate
# File when/tmreference.rb, line 420
420: def ^(date, options={})
421: date = date.any_other if date.kind_of?(Position)
422: my_options = (date.options||{}).merge(options)
423: frac = self.universal_time
424: sdn, time = (date.universal_time - frac).divmod(IntervalLength::DAY)
425: my_options[:frame] ||= date.frame if date.kind_of?(CalDate)
426: my_options[:clock] = self
427: case date
428: when DateAndTime
429: return DateAndTime.new(my_options[:frame].to_cal_date(sdn + JulianDate::JD19700101), time+frac, my_options)
430: when CalDate
431: return CalDate.new(my_options[:frame].to_cal_date(date.to_i), my_options)
432: when JulianDate
433: my_options[:frame] = my_options.delete(:clock)
434: return JulianDate.new(sdn * IntervalLength::DAY, my_options)
435: else
436: raise TypeError, "Irregal (Temporal)Position"
437: end
438: end
時刻をNumeric(serial time)に変換する
Description of an operation for converting a time in the specified clock to a Unix Time
clk_time : [Numeric] returns : Numeric of serial time
# File when/tmreference.rb, line 385
385: def _coordinates_to_number(clk_time)
386: u = 1
387: s = 0
388: (@base.length-1).downto(1) do |i|
389: s += u * (+clk_time[i] - @base[i]) if (clk_time[i])
390: u *= @unit[i]
391: end
392: return s + u * (+clk_time[0]) + @origin_of_LSD
393: end
Numeric(serial time)を時刻に変換する
Description of an operation for converting a Unix Time to a time in the specified clock
serial_time : Numeric of serial time returns : [Numeric]
# File when/tmreference.rb, line 403
403: def _number_to_coordinates(serial_time)
404: time = [serial_time-@origin_of_LSD]
405: (@base.length-1).downto(1) do |i|
406: carry, time[0] = (+time[0]).divmod(@unit[i])
407: time[0] += @base[i]
408: time.unshift(carry)
409: end
410: return time
411: end
UTC時刻をこの時法の時刻に変換する
Description of an operation for converting a UTC time to a time on this clock
clk_time : When::TM::ClockTime returns : When::TM::ClockTime
# File when/tmreference.rb, line 343
343: def clk_trans(clk_time)
344: return self.to_clk_time(When.utc.to_universal_time(u_time.clk_time))
345: end
この時法のUTCとの差(ISO 8601 basic format)
returns : String (±hhmm)
# File when/tmreference.rb, line 463
463: def to_basic
464: return '' unless @zone
465: @zone.gsub(/:/, '')
466: end
日の小数をこの時法の時刻に変換する
Description of an operation for converting a day fraction time to a time on this clock
fod : Numeric returns : When::TM::ClockTime
# File when/tmreference.rb, line 368
368: def to_clk_time(fod, options={})
369: options[:frame] = self
370: fod, second = fod.trunk, fod.branch / fod.second if fod.kind_of?(When::Coordinates::LeapSeconds)
371: clk_time = ClockTime.new(_encode(_number_to_coordinates(fod * @second)), options)
372: return clk_time if (second||0) == 0
373: clk_time.clk_time[1] += second
374: return clk_time
375: end
この時法の時刻を日の小数に変換する
Description of an operation for converting a time on this clock to a day fraction time
clk_time : [Numeric] returns : Numeric
# File when/tmreference.rb, line 356
356: def to_universal_time(clk_time)
357: return _coordinates_to_number(_decode(clk_time)) / @second
358: end
この時法の時間帯名
index : :all or Integer(default 0)
時間帯名が複数付与されている場合を想定して、番号で個別に取得できるようにしている。
:all を指定すると Array で、付与されているすべての時間帯名を取得できる。
extended : Boolean
true - ISO 8601 extended format (default)
false - ISO 8601 basic format
時間帯名が付与されていない場合は、ISO 8601形式で返す
returns : String or [String]
# File when/tmreference.rb, line 452
452: def tzname(index=0, extended=true)
453: name = @tz_prop.tzname if @tz_prop
454: name ||= extended ? @zone : to_basic
455: name = [name] unless name.kind_of?(Array)
456: return index.kind_of?(Integer) ? name[index] : name
457: end
日の小数による参照事象の時刻
Fraction time of the reference event
type : Numeric T00:00:00Z からの参照事象の経過時間 / 128秒
# File when/tmreference.rb, line 318
318: def universal_time
319: return @utc_reference.universal_time
320: end
この時法の時刻をUTC時刻に変換する
Description of an operation for converting a time on this clock to a UTC time
u_time : When::TM::ClockTime returns : When::TM::ClockTime
# File when/tmreference.rb, line 330
330: def utc_trans(u_time)
331: return When.utc.to_clk_time(self.to_universal_time(u_time.clk_time))
332: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.