Method: Suntrack::RAstro.to_mjd
- Defined in:
- lib/suntrack/RAstro.rb
.to_mjd(date_time) ⇒ Object
Utility method to convert Ruby DateTime to modified Julian date M&P, page 12
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/suntrack/RAstro.rb', line 64 def self.to_mjd(date_time) a = (10000 * date_time.year) + (100 * date_time.month) + date_time.mday m = date_time.month y = date_time.year if date_time.month <= 2 m = date_time.month + 12 y = date_time.year - 1 end leapDays = (y/400).to_i - (y/100).to_i + (y/4).to_i if a <= 15821004.1 leapDays = -2 + ((y+4716)/4).to_i - 1179 end a = (365 * y) - 679004 a + leapDays + (30.6001 * (m + 1)).to_i + date_time.mday + (Float(date_time.hour)/24) + (Float(date_time.min)/1440) + (Float(date_time.sec)/86400) end |