// Generated by CoffeeScript 1.12.5
import Ember from 'ember';

export default Ember.Controller.extend({
  set_value_on_non_final_till_date_date: moment(),
  set_value_on_non_final_till_date_action: null,
  operation_running_time: Ember.computed('globals.operation_running', function() {
    var duration, hours, minutes, seconds, start_time;
    if (!(start_time = this.get('globals.operation_running'))) {
      return '';
    }
    duration = moment.duration(moment().diff(start_time));
    if (duration.days()) {
      return (duration.days()) + " days and " + (duration.hours()) + " hours";
    } else {
      hours = ('0' + duration.hours()).slice(-2);
      minutes = ('0' + duration.minutes()).slice(-2);
      seconds = ('0' + duration.seconds()).slice(-2);
      return hours + ":" + minutes + ":" + seconds;
    }
  }),
  actions: {
    set_value_on_non_final_till_date: function() {
      var action, date;
      if (!(date = this.get('set_value_on_non_final_till_date_date'))) {
        return;
      }
      if (!(action = this.get('set_value_on_non_final_till_date_action'))) {
        return;
      }
      this.set('globals.operation_running', moment());
      return action.set_value_on_non_final_till_date({
        date: date.format('YYYY-MM-DD'),
        event_value: 't'
      });
    }
  }
});
