Module: IERS::TimeScale Private

Defined in:
lib/iers/time_scale.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Constant Summary collapse

JD_MJD_OFFSET =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

2_400_000.5
JD_J2000 =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

2_451_545.0
MJD_J2000 =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

51_544.5
DAYS_PER_JULIAN_CENTURY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

36_525.0
SECONDS_PER_DAY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

86_400.0
ARCSEC_TO_RAD =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Math::PI / 648_000.0
TT_TAI =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

seconds

32.184

Class Method Summary collapse

Class Method Details

.to_date(mjd) ⇒ Date

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • mjd (Float)

    Modified Julian Date

Returns:

  • (Date)


20
21
22
# File 'lib/iers/time_scale.rb', line 20

def to_date(mjd)
  Date.jd((mjd.floor + JD_MJD_OFFSET).ceil)
end

.to_mjd(input = nil, jd: nil, mjd: nil) ⇒ Float

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Modified Julian Date.

Parameters:

  • input (Time, Date, DateTime, nil) (defaults to: nil)
  • jd (Float, nil) (defaults to: nil)

    Julian Date

  • mjd (Float, nil) (defaults to: nil)

    Modified Julian Date

Returns:

  • (Float)

    Modified Julian Date

Raises:

  • (ArgumentError)

    if no valid input is provided



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/iers/time_scale.rb', line 29

def to_mjd(input = nil, jd: nil, mjd: nil)
  if mjd
    Float(mjd)
  elsif jd
    Float(jd) - JD_MJD_OFFSET
  elsif input.is_a?(Time)
    input.to_datetime.ajd.to_f - JD_MJD_OFFSET
  elsif input.is_a?(Date)
    input.ajd.to_f - JD_MJD_OFFSET
  else
    raise ArgumentError,
      "Expected Time, Date, DateTime, jd: or mjd: keyword, " \
      "got #{input.inspect}"
  end
end