<commit_before>import Ember from 'ember';

export default Ember.Component.extend({
  classNames: ['input-group', 'input-group-sm', 'date'],

  date: null,
  minDate: false,
  maxDate: false,
  onChange: Ember.K,

  didInsertElement() {
    this.$().datetimepicker({
      pickDate: false,
      useSeconds: true,
      format: 'HH:mm:ss',
      icons: {
        time: 'icon-time',
        date: 'icon-calendar',
        up: 'icon-chevron-up',
        down: 'icon-chevron-down',
      },
      minDate: this.get('minDate'),
      maxDate: this.get('maxDate'),
    });

    this.$().on('dp.change', ({ date }) => {
      this.get('onChange')(date.toDate());
    });

    this.set('picker', this.$().data('DateTimePicker'));

    Ember.run.once(this, 'updateDate');
  },

  didUpdateAttrs() {
    Ember.run.once(this, 'updateDate');
  },

  willDestroyElement() {
    this.$().off('dp.change');
    this.set('picker', null);
  },

  updateDate() {
    this.get('picker').setValue(this.get('date'));
  },
});<commit_msg>components/datetime-picker: Fix potential TypeError when picker was set to null<commit_after>import Ember from 'ember';

export default Ember.Component.extend({
  classNames: ['input-group', 'input-group-sm', 'date'],

  date: null,
  minDate: false,
  maxDate: false,
  onChange: Ember.K,

  didInsertElement() {
    this.$().datetimepicker({
      pickDate: false,
      useSeconds: true,
      format: 'HH:mm:ss',
      icons: {
        time: 'icon-time',
        date: 'icon-calendar',
        up: 'icon-chevron-up',
        down: 'icon-chevron-down',
      },
      minDate: this.get('minDate'),
      maxDate: this.get('maxDate'),
    });

    this.$().on('dp.change', ({ date }) => {
      this.get('onChange')(date.toDate());
    });

    this.set('picker', this.$().data('DateTimePicker'));

    Ember.run.once(this, 'updateDate');
  },

  didUpdateAttrs() {
    Ember.run.once(this, 'updateDate');
  },

  willDestroyElement() {
    this.$().off('dp.change');
    this.set('picker', null);
  },

  updateDate() {
    let picker = this.get('picker');
    if (picker) {
      picker.setValue(this.get('date'));
    }
  },
});
{'fraction_non_alphanumeric': 0.20148906468124708, 'fraction_numerical': 0.0, 'mean_word_length': 2.8530465949820787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '397356', 'n_tokens_mistral': 744, 'n_tokens_neox': 726, 'n_words': 126}