Class: When::TimeStandard::TemporalHourSystem

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

Overview

不定時法

Constant Summary

Constants inherited from TimeStandard

When::TimeStandard::TimeStandard::Ratio

Constants included from When::TimeStandard

DeltaT, DeltaT0, TAI_UTC

Constants included from Namespace

Namespace::DC, Namespace::DCQ, Namespace::DCT, Namespace::FOAF, Namespace::OWL, Namespace::RDF, Namespace::RDFC, Namespace::RDFS, Namespace::RSS, Namespace::XSD

Instance Attribute Summary

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#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

_setup_, _setup_info, 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

#[], #^, _instance, _setup_, _setup_info, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #parent, #registered?, root_dir

Methods included from Parts::Resource::Pool

#[], #[]=, #_setup_

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(time) ⇒ Numeric

dynamical time を temporal hour system に変換する

Parameters:

  • time (Numeric)

    dynamical time

Returns:

  • (Numeric)

    temporal hour system



671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# File 'lib/when_exe/timestandard.rb', line 671

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:



648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
# File 'lib/when_exe/timestandard.rb', line 648

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