// Generated by CoffeeScript 1.10.0
(function() {
  var time12hrFormat;

  time12hrFormat = "g:ia";

  $(function() {
    var phpDateFormatter, ref;
    if ((((ref = $.datetimepicker) != null ? ref.setDateFormatter : void 0) != null) && (typeof moment !== "undefined" && moment !== null)) {
      time12hrFormat = "moment+12hr";
      phpDateFormatter = new DateFormatter();
      $.datetimepicker.setDateFormatter({
        parseDate: function(date, format) {
          var mo;
          if (format === "moment+12hr") {
            mo = moment(date, ["h:mma", "ha", "h:m:sa", "HH:mm", "HH:mm:s", "h"]);
            if (mo.isValid()) {
              return mo.toDate();
            } else {
              return false;
            }
          } else {
            return phpDateFormatter.parseDate(date, format);
          }
        },
        formatDate: function(date, format) {
          if (format === "moment+12hr") {
            return moment(date).format("h:mma");
          } else {
            return phpDateFormatter.formatDate(date, format);
          }
        }
      });
    }
  });

  this.initTime12hrChooser = function(id) {
    $('#' + id).datetimepicker({
      datepicker: false,
      formatTime: time12hrFormat,
      format: time12hrFormat,
      step: 30
    });
  };

}).call(this);
