ok… for the sake of archival needs and in case anyone else tries to

do this… here’s what my final solution was…

this is in the model for the class that holds the “day of work” so to

speak…

#if the start time is greater than the end time, move end time to Jan

2nd

if self.finish_time < self.call_time

#add 86, 400 seconds

self.finish_time += ( 60 * 60 * 24 )

end

# calculate the total time in seconds, convert to hours… and round to

the next full interger( .ceil ) ( 2.01 becomes 3 because they are paid

for every hour or part thereof )

hours_worked = ( ( self.finish_time - self.call_time ) / 3600 ).ceil

#-create constants to hold the point in time where 6AM and 11PM are on

Jan1st and 2nd

jan_one_eleven_pm_epoch = 946785600

jan_one_six_am_epoch = 946724400

jan_two_six_am_epoch = 946810800

##- night premiums

#- check to see if clal time or end time falls between OT period ( need

to do more to check if the employee works 10Pm to 7AM for example…

but that’s easy )

if( self.call_time.to_i >= jan_one_eleven_pm_epoch ||

self.call_time.to_i <= jan_one_six_am_epoch ||

( self.finish_time.to_i <= jan_two_six_am_epoch &&

self.finish_time.to_i >= jan_one_eleven_pm_epoch ) )

##
#- use the call_time or use 11PM, use finish or use 6AM etc… convert

to Float and convert to hours

night_hours = ( minimum( self.finish_time.to_i, jan_two_six_am_epoch )

```
maximum( self.call_time.to_i,
```

jan_one_eleven_pm_epoch ) ).to_f / 3600

##private methods from Chirs…

private

def maximum(a,b)

a>b ? a : b

end

def minimum(a,b)

a<b ? a : b

end

Works like a charm!