72 lines
2.3 KiB
TypeScript
Raw Normal View History

import { Component, OnInit, Input } from '@angular/core';
import {
Info,
PlanEventJson,
PlanContentType
} from '@ucap-webmessenger/protocol-event';
import moment from 'moment';
2019-10-07 13:49:12 +09:00
@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;
2019-10-07 13:49:12 +09:00
constructor() {}
ngOnInit() {
if (!!this.message && !!this.message.sentMessageJson) {
if (!!this.message.sentMessageJson.date) {
let str_date = this.message.sentMessageJson.date
.replace(/ /g, '')
.replace(/\n/g, '')
.replace(/(\([월,화,수,목,금,토,일]\))/g, '');
if (str_date.indexOf('오전') > -1) {
str_date = str_date.replace('오전', ' ');
} else if (str_date.indexOf('오후') > -1) {
str_date = str_date.replace('오후', ' ');
const arr = str_date.split(' ');
let h = Number(arr[1].split(':')[0]) + 12;
str_date = arr[0] + ' ' + h + ':' + arr[1].split(':')[1];
}
this.date = moment(str_date).toDate();
if (this.date === 'Invalid Date') {
this.date = this.message.sentMessageJson.date.replace(/\n/g, '');
}
}
// if (!!this.message.sentMessageJson.endDate) {
// let str_endDate = this.message.sentMessageJson.endDate
// .replace(/ /g, '')
// .replace(/\n/g, '')
// .replace(/(\([월,화,수,목,금,토,일]\))/g, '');
// if (str_endDate.indexOf('오전') > -1) {
// str_endDate = str_endDate.replace('오전', ' ');
// } else if (str_endDate.indexOf('오후') > -1) {
// str_endDate = str_endDate.replace('오후', ' ');
// const arr = str_endDate.split(' ');
// let h = Number(arr[1].split(':')[0]) + 12;
// str_endDate = arr[0] + ' ' + h + ':' + arr[1].split(':')[1];
// }
// this.endDate = moment(str_endDate).toDate();
// if (this.endDate === 'Invalid Date') {
// this.endDate = this.message.sentMessageJson.endDate.replace(
// /\n/g,
// ''
// );
// }
// }
}
}
2019-11-06 13:48:06 +09:00
onClickSave(): void {}
2019-10-07 13:49:12 +09:00
}