72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { Component, OnInit, Input } from '@angular/core';
|
|
import {
|
|
Info,
|
|
PlanEventJson,
|
|
PlanContentType
|
|
} from '@ucap-webmessenger/protocol-event';
|
|
import moment from 'moment';
|
|
|
|
@Component({
|
|
selector: 'ucap-chat-message-box-schedule',
|
|
templateUrl: './schedule.component.html',
|
|
styleUrls: ['./schedule.component.scss']
|
|
})
|
|
export class ScheduleComponent implements OnInit {
|
|
@Input()
|
|
message: Info<PlanEventJson>;
|
|
|
|
PlanContentType = PlanContentType;
|
|
date: any;
|
|
endDate: any;
|
|
|
|
constructor() {}
|
|
|
|
ngOnInit() {
|
|
if (!!this.message && !!this.message.sentMessageJson) {
|
|
if (!!this.message.sentMessageJson.date) {
|
|
let strDate = this.message.sentMessageJson.date
|
|
.replace(/ /g, '')
|
|
.replace(/\n/g, '')
|
|
.replace(/(\([월,화,수,목,금,토,일]\))/g, '');
|
|
if (strDate.indexOf('오전') > -1) {
|
|
strDate = strDate.replace('오전', ' ');
|
|
} else if (strDate.indexOf('오후') > -1) {
|
|
strDate = strDate.replace('오후', ' ');
|
|
const arr = strDate.split(' ');
|
|
const h = Number(arr[1].split(':')[0]) + 12;
|
|
strDate = arr[0] + ' ' + h + ':' + arr[1].split(':')[1];
|
|
}
|
|
|
|
this.date = moment(strDate).toDate();
|
|
if (this.date === 'Invalid Date') {
|
|
this.date = this.message.sentMessageJson.date.replace(/\n/g, '');
|
|
}
|
|
}
|
|
// if (!!this.message.sentMessageJson.endDate) {
|
|
// let strEndDate = this.message.sentMessageJson.endDate
|
|
// .replace(/ /g, '')
|
|
// .replace(/\n/g, '')
|
|
// .replace(/(\([월,화,수,목,금,토,일]\))/g, '');
|
|
// if (strEndDate.indexOf('오전') > -1) {
|
|
// strEndDate = strEndDate.replace('오전', ' ');
|
|
// } else if (strEndDate.indexOf('오후') > -1) {
|
|
// strEndDate = strEndDate.replace('오후', ' ');
|
|
// const arr = strEndDate.split(' ');
|
|
// const h = Number(arr[1].split(':')[0]) + 12;
|
|
// strEndDate = arr[0] + ' ' + h + ':' + arr[1].split(':')[1];
|
|
// }
|
|
|
|
// this.endDate = moment(strEndDate).toDate();
|
|
// if (this.endDate === 'Invalid Date') {
|
|
// this.endDate = this.message.sentMessageJson.endDate.replace(
|
|
// /\n/g,
|
|
// ''
|
|
// );
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
onClickSave(): void {}
|
|
}
|