Class: When::TimeStandard::TemporalHourSystem
- Inherits:
-
LocalApparentTime
- Object
- BasicTypes::Object
- TimeStandard
- LocalApparentTime
- When::TimeStandard::TemporalHourSystem
- Defined in:
- lib/when_exe/timestandard.rb
Overview
不定時法
Constant Summary
Constants inherited from TimeStandard
When::TimeStandard::TimeStandard::Ratio
Constants included from When::TimeStandard
Constants included from Parts::Resource
Parts::Resource::LabelProperty, Parts::Resource::Prefix, Parts::Resource::PrefixIndex, Parts::Resource::PrefixKeys, Parts::Resource::PrefixValues
Instance Attribute Summary
Attributes inherited from BasicTypes::Object
Attributes included from Parts::Resource
#_pool, #child, #keys, #locale, #namespace
Instance Method Summary collapse
- #_from_dynamical_time ⇒ Object
- #_to_dynamical_time ⇒ Object
-
#from_dynamical_time(time) ⇒ Numeric
dynamical time を temporal hour system に変換する.
-
#to_dynamical_time(time) ⇒ Numeric
temporal hour system を dynamical time に変換する.
Methods inherited from TimeStandard
#from_dynamical_date, #from_time_object, #has_leap?, #rate_of_clock, #to_dynamical_date, #to_time_object
Methods included from When::TimeStandard
_is_systemtime_universal?, _leap_seconds, _setup_, delta_t, delta_t_coordinated, delta_t_observed, from_dynamical_time, from_time_object, to_dynamical_time, to_time_object
Methods inherited from BasicTypes::Object
Methods included from Parts::Resource
#[], #^, _extract_prefix, _instance, _parse, _path_with_prefix, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?
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::Parts::Resource
Instance Method Details
#_from_dynamical_time ⇒ Object
477 |
# File 'lib/when_exe/timestandard.rb', line 477 alias :_from_dynamical_time :from_dynamical_time |
#_to_dynamical_time ⇒ Object
475 |
# File 'lib/when_exe/timestandard.rb', line 475 alias :_to_dynamical_time :to_dynamical_time |
#from_dynamical_time(time) ⇒ Numeric
dynamical time を temporal hour system に変換する
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/when_exe/timestandard.rb', line 508 def from_dynamical_time(time) date = When::TM::JulianDate._t_to_d(time) d, t = [-1, +1].map {|v| @formula.day_event(date, v, When.Resource('_ep:Sun'), @height)} if date < d # after midnight t = @formula.sun_set(date-1, @height) f = (date - t) / (d - t) / 2 - 0.25 elsif date > t # before midnight d = @formula.sun_rise(date+1, @height) f = (date - t) / (d - t) / 2 - 0.25 else # day time f = (date - d) / (t - d) / 2 + 0.25 end When::TM::JulianDate._d_to_t(_from_dynamical_date(d).floor + 0.5 + f) end |
#to_dynamical_time(time) ⇒ Numeric
temporal hour system を dynamical time に変換する
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/when_exe/timestandard.rb', line 485 def to_dynamical_time(time) noon, frac = When::TM::JulianDate._t_to_d(time).divmod(1) r, *p = case (frac * 4).floor when 3 ; [-1.5, [noon+1, -1],[noon+1, +1]] # morning when 0 ; [+0.5, [noon, -1],[noon, +1]] # afternoon else ; [-0.5, [noon, +1],[noon+1, -1]] # night end s, e = p.map {|v| When::TM::JulianDate._d_to_t(@formula.day_event(_to_dynamical_date(v[0]), v[1], When.Resource('_ep:Sun'), @height)) } s + (e - s) * (frac * 2 + r) end |