Method: Time.mdy2julian

Defined in:
lib/openc3/core_ext/time.rb

.mdy2julian(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, us = 0) ⇒ Float

Convert the given year, month, day, hour, minute, second, and us into a Julian date. Julian dates are the number of days (plus fractional days) since Jan 1, 4713 BC at noon.

Parameters:

  • year (Integer)
  • month (Integer) (defaults to: 1)
  • day (Integer) (defaults to: 1)
  • hour (Integer) (defaults to: 0)
  • minute (Integer) (defaults to: 0)
  • second (Integer) (defaults to: 0)
  • us (Integer) (defaults to: 0)

Returns:

  • (Float)

    The given time as a Julian date



170
171
172
173
174
# File 'lib/openc3/core_ext/time.rb', line 170

def self.mdy2julian(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, us = 0)
  # Note DateTime does not support fractions of seconds
  date_time = DateTime.new(year, month, day, hour, minute, second)
  (date_time - DATE_TIME_MJD_EPOCH).to_f + JULIAN_DATE_OF_MJD_EPOCH + us / USEC_PER_DAY_FLOAT
end