Commits

Anonymous committed 217424a

Have Calculation working

Comments (0)

Files changed (1)

CalcHours/lib/calc_hours.rb

 
 class CalcHours < FXMainWindow
   def initialize(app)
-    super(app, "Calculate Hours", :width=>350, :height=>150)
-    
-    
-
-    @lunch_stop = FXDataTarget.new
+    super(app, "Calculate Hours", :width=>350, :height=>175)
     
     main = FXVerticalFrame.new(self)
     matrix = FXMatrix.new(main, 2, :opts=> MATRIX_BY_COLUMNS|LAYOUT_FILL)
     buttons = FXHorizontalFrame.new(main, :opts=>LAYOUT_RIGHT)
     compute = FXButton.new(buttons, "Compute", :opts=> JUSTIFY_RIGHT|BUTTON_NORMAL)
     compute.connect(SEL_COMMAND) do |sender, sel, data|
-      
-      FXMessageBox.information(self, MBOX_OK, "Start Time", "#{@start_time.text}" )
+      time_start = DateTime.strptime(@start_time.text, "%H:%M")
+      start_hours = time_start.hour.to_f + (time_start.min.to_f / 60 )
+      start_lunch = DateTime.strptime(@lunch_start.text, "%H:%M")
+      start_lunch_hours = start_lunch.hour.to_f + (start_lunch.min.to_f / 60 )
+      stop_lunch = DateTime.strptime(@lunch_stop.text, "%H:%M")
+      stop_lunch_hours = stop_lunch.hour.to_f + (stop_lunch.min.to_f / 60 )
+      time_stop = DateTime.strptime(@stop_time.text, "%H:%M")
+      stop_hours = time_stop.hour.to_f + (time_stop.min.to_f / 60 )
+      result = (start_lunch_hours - start_hours).to_f + (stop_hours - stop_lunch_hours)
+      @results.text = result.to_s
+      #FXMessageBox.information(self, MBOX_OK, "Start Time", "#{time_start}" )
     end
 
   end