Module: IERS::LeapSecond

Defined in:
lib/iers/leap_second.rb

Defined Under Namespace

Classes: Entry

Class Method Summary collapse

Class Method Details

.allArray<Entry>

Returns:



15
16
17
18
19
20
21
22
23
24
# File 'lib/iers/leap_second.rb', line 15

def all
  @mutex.synchronize do
    @all ||= IERS::Data.leap_second_entries.map do |parser_entry|
      Entry.new(
        effective_date: parser_entry.date,
        tai_utc: parser_entry.tai_utc
      )
    end.freeze
  end
end

.at(input = nil, jd: nil, mjd: nil) ⇒ Integer

Returns TAI−UTC in seconds.

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:

  • (Integer)

    TAI−UTC in seconds

Raises:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/iers/leap_second.rb', line 44

def at(input = nil, jd: nil, mjd: nil)
  query_mjd = TimeScale.to_mjd(input, jd: jd, mjd: mjd)
  parser_entries = IERS::Data.leap_second_entries

  first_mjd = parser_entries.first.mjd
  last_mjd = parser_entries.last.mjd

  if query_mjd < first_mjd
    raise OutOfRangeError.new(
      "Requested MJD #{query_mjd} is before the first leap second " \
      "entry (MJD #{first_mjd})",
      requested_mjd: query_mjd,
      available_range: first_mjd..last_mjd
    )
  end

  index = parser_entries.bsearch_index { |e| e.mjd > query_mjd }

  if index.nil?
    parser_entries.last.tai_utc
  else
    parser_entries[index - 1].tai_utc
  end
end

.clear_cached!void

This method returns an undefined value.



27
28
29
30
31
# File 'lib/iers/leap_second.rb', line 27

def clear_cached!
  @mutex.synchronize do
    @all = nil
  end
end

.next_scheduledEntry?

Returns:



34
35
36
37
# File 'lib/iers/leap_second.rb', line 34

def next_scheduled
  today = Date.today
  all.find { |entry| entry.effective_date > today }
end