Class: When::TimeStandard::TemporalHourSystem

Inherits:
LocalApparentTime show all
Defined in:
lib/when_exe/timestandard.rb

Overview

不定時法

Constant Summary

Constants inherited from TimeStandard

When::TimeStandard::TimeStandard::Ratio

Constants included from When::TimeStandard

DeltaT, DeltaT0, DeltaThreshold, TAI_UTC, YearThreshold

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Instance Method Summary collapse

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, delta_t_observed_nasa, delta_t_observed_poly, from_dynamical_time, from_time_object, to_dynamical_time, to_time_object

Methods included from Parts::Resource

#[], #^, _decode, _encode, _extract_prefix, _instance, _parse, _path_with_prefix, _replace_tags, _setup_, #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

#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_timeObject


600
# File 'lib/when_exe/timestandard.rb', line 600

alias :_from_dynamical_time :from_dynamical_time

#_to_dynamical_timeObject


598
# File 'lib/when_exe/timestandard.rb', line 598

alias :_to_dynamical_time   :to_dynamical_time

#from_dynamical_time(time) ⇒ Numeric

dynamical time を temporal hour system に変換する

Parameters:

  • time (Numeric)

    dynamical time

Returns:

  • (Numeric)

    temporal hour system


631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
# File 'lib/when_exe/timestandard.rb', line 631

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.sunset(date-1, @height)
    f = (date - t) / (d - t) / 2 - 0.25

  elsif date > t # before midnight
    d = @formula.sunrise(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 に変換する

Parameters:

  • time (Numeric)

    temporal hour system

Returns:


608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
# File 'lib/when_exe/timestandard.rb', line 608

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