Sha256: 4ac9c3063e7dec166d58bf42e0374018e5a129a96ba57f017245e214f74fd825
Contents?: true
Size: 1.51 KB
Versions: 8
Compression:
Stored size: 1.51 KB
Contents
class Date FOS_JD_OFFSET_DAYS = Date.parse('1899-12-31').jd DATE_FORMATS[:mdy] = "%m/%d/%Y" def self.from_fos_days(days) self.jd(FOS_JD_OFFSET_DAYS + days) end def to_fos_days jd - FOS_JD_OFFSET_DAYS end end class Time DATE_FORMATS[:hm] = "%H:%M" alias :original_to_s :to_s def to_s(args=nil) args = :hm unless args self.original_to_s(args) end # creates utc time from minutes def self.from_fos_time(minutes) DateTime.new(2000,1,1).advance(:minutes=>minutes).to_time end def as_minutes hour*60 + min end def in_hundredths return 0 if hour + min == 0 minutes = hour*60 + min val = "#{minutes/60}.#{((100*(minutes.modulo(60)))/60).to_s.rjust(2,'0')}" BigDecimal.new(val, 2).round(1).to_s end def in_hundredths_rounded_XOJET_style return 0 if hour + min == 0 # It was determined that "ODD" increments of .05 (ie .15, .35, .55, .75, .95) of an hour (ie. 9,21,33,45,57 minutes) rounded UP whereas even increments of .05 rounded DOWN - sn minutes = hour*60 + min (minutes/60.0 + ([9, 21, 33, 45, 57].include?( min ) ? 0.001 : -0.001)).round(2) #minutes/60.0 end def in_tenths_rounded_XOJET_style return 0 if hour + min == 0 # It was determined that "ODD" increments of .05 (ie .15, .35, .55, .75, .95) of an hour (ie. 9,21,33,45,57 minutes) rounded UP whereas even increments of .05 rounded DOWN - sn minutes = hour*60 + min (minutes/60.0 + ([9, 21, 33, 45, 57].include?( min ) ? 0.01 : -0.01)).round(1) end end
Version data entries
8 entries across 8 versions & 1 rubygems