Hamilton LaboratoriesHamilton C shell 2012User guideSamples

deltahrs.csh

Oregon Coast

deltahrs.csh
Previous | Next

#  Calculate the difference in hours and fractions of an hour between
#  two times, given in hours and minutes.
#  Copyright (c) 2009-2012 by Hamilton Laboratories.  All rights reserved.


proc minutes( t )
   return ( t - floor( t ) ) * 100
end

proc deltahrs( begin, end )
   local delta, hours, mins
   set begin = $begin:S/:/./
   set end = $end:S/:/./
   if ( end < begin ) then
      @ end += 12
   end
   @ hours = floor( end ) - floor( begin )
   @ mins = minutes( end ) - minutes( begin )
   if ( mins < 0 ) then
      @ hours--
      @ mins += 60
   end
   return hours + mins/60
end

deltahrs $argv

Previous | Next