<commit_before>import { Component, Input, Output, EventEmitter, AfterViewInit, ViewChild, ElementRef } from '@angular/core';
import * as Pikaday from 'pikaday';
import * as moment from 'moment';

@Component({
  selector: 'publish-datepicker',
  template: `
    <span class="input-group">
      <input type="text" #datepicker [value]="formattedDate">
      <span class="input-group-addon" (click)="datepicker.click()"><img src="assets/images/calendar.svg"></span>
    </span>
  `,
  styleUrls: ['datepicker.component.css']
})

export class DatepickerComponent implements AfterViewInit{
  public static FORMAT = 'MM/DD/YYYY';

  @Input() date: Date;
  @Output() onDateChange = new EventEmitter<Date>();
  @ViewChild('datepicker') input: ElementRef;

  private picker: Pikaday;

  get formattedDate(): string {
    if (this.date) {
      return moment(this.date.valueOf()).format(DatepickerComponent.FORMAT);
    }
  }

  ngAfterViewInit() {
    let options = {
      field: this.input.nativeElement,
      format: DatepickerComponent.FORMAT,
      theme: 'triangle-theme',
      onSelect: () => {
        this.onDateChange.emit(this.picker.getDate());
      }
    };
    if (this.date) {
      // publishedAt is declared as a Date. why is it a string?
      let defaultDate = new Date(this.date.valueOf());
      options['defaultDate'] = (defaultDate.getMonth() + 1) + '/' + defaultDate.getDate() + '/' + defaultDate.getFullYear();
      options['setDefaultDate'] = true;
    }
    this.picker = new Pikaday(options);
  }
}<commit_msg>clean up setting the defaultDate<commit_after>import { Component, Input, Output, EventEmitter, AfterViewInit, ViewChild, ElementRef } from '@angular/core';
import * as Pikaday from 'pikaday';
import * as moment from 'moment';

@Component({
  selector: 'publish-datepicker',
  template: `
    <span class="input-group">
      <input type="text" #datepicker [value]="formattedDate">
      <span class="input-group-addon" (click)="datepicker.click()"><img src="assets/images/calendar.svg"></span>
    </span>
  `,
  styleUrls: ['datepicker.component.css']
})

export class DatepickerComponent implements AfterViewInit{
  public static FORMAT = 'MM/DD/YYYY';

  @Input() date: Date;
  @Output() onDateChange = new EventEmitter<Date>();
  @ViewChild('datepicker') input: ElementRef;

  private picker: Pikaday;

  get formattedDate(): string {
    if (this.date) {
      return moment(this.date.valueOf()).format(DatepickerComponent.FORMAT);
    }
  }

  ngAfterViewInit() {
    let options = {
      field: this.input.nativeElement,
      format: DatepickerComponent.FORMAT,
      theme: 'triangle-theme',
      onSelect: () => {
        this.onDateChange.emit(this.picker.getDate());
      }
    };
    if (this.date) {
      options['defaultDate'] = new Date(this.date.valueOf());
      options['setDefaultDate'] = true;
    }
    this.picker = new Pikaday(options);
  }
}
{'fraction_non_alphanumeric': 0.1522562866000689, 'fraction_numerical': 0.0003444712366517396, 'mean_word_length': 3.7219512195121953, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '5314902', 'n_tokens_mistral': 915, 'n_tokens_neox': 884, 'n_words': 195}