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::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIDecode, Parts::Resource::IRIDecodeTable, Parts::Resource::IRIEncode, Parts::Resource::IRIEncodeTable, Parts::Resource::IRIHeader, 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 included from LocalTime

#localdate_difference, #localtime_difference

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_, _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

#[], #^, _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, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?, root_dir

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



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

alias :_from_dynamical_time :from_dynamical_time

#_to_dynamical_timeObject



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

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



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

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:



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

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