Module: TimeFunctions

Included in:
DateTime, Time
Defined in:
lib/sequel/fos_dates.rb

Instance Method Summary collapse

Instance Method Details

#as_minutesObject



32
33
34
# File 'lib/sequel/fos_dates.rb', line 32

def as_minutes
  hour*60 + min
end

#hmObject



59
60
61
# File 'lib/sequel/fos_dates.rb', line 59

def hm
  strftime("%H:%M")
end

#in_hundredthsObject



36
37
38
39
40
41
# File 'lib/sequel/fos_dates.rb', line 36

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(2).to_f
end

#in_hundredths_rounded_xosObject

xos is rounding XOJET STYLE, which is a funky copy of how ipc did it



44
45
46
47
48
49
# File 'lib/sequel/fos_dates.rb', line 44

def in_hundredths_rounded_xos
  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 = as_minutes
  (minutes/60.0 + ([9, 21, 33, 45, 57].include?(min) ? 0.001 : -0.001)).round(2)
end

#in_tenths_rounded_xosObject

xos is rounding XOJET STYLE, which is a funky copy of how ipc did it



52
53
54
55
56
57
# File 'lib/sequel/fos_dates.rb', line 52

def in_tenths_rounded_xos
  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 = as_minutes
  (minutes/60.0 + ([9, 21, 33, 45, 57].include?(min) ? 0.01 : -0.01)).round(1)
end

#to_fos_daysObject



63
64
65
# File 'lib/sequel/fos_dates.rb', line 63

def to_fos_days
  to_date.to_fos_days
end