import { Component, OnInit, Input } from '@angular/core';
import { Info, EventJson } from '@ucap-webmessenger/protocol-event';
import { DatePipe } from '@angular/common';
import moment from 'moment';

@Component({
  selector: 'ucap-chat-message-box-date-splitter',
  templateUrl: './date-splitter.component.html',
  styleUrls: ['./date-splitter.component.scss'],
})
export class DateSplitterComponent implements OnInit {
  @Input()
  message: Info<EventJson>;

  dateInfo: string;

  constructor(private datePipe: DatePipe) {}

  ngOnInit() {
    this.dateInfo = this.datePipe.transform(
      moment(this.message.sendDate).toDate(),
      'yyyy.MM.dd EEE'
    );
  }
}
