From bd020944aa12e38d347f5091eeaca84daf4a47b7 Mon Sep 17 00:00:00 2001 From: Pardiez Date: Thu, 8 Dec 2016 13:22:06 +0100 Subject: [PATCH] refactor: extract dates to task form --- app/src/pages/task-form/task-form.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/pages/task-form/task-form.ts b/app/src/pages/task-form/task-form.ts index c83fb27..cec61b8 100644 --- a/app/src/pages/task-form/task-form.ts +++ b/app/src/pages/task-form/task-form.ts @@ -5,6 +5,7 @@ import { TranslateService } from 'ng2-translate'; import { Task } from '../../models/task'; import { Tasks } from '../tasks/tasks'; import { TaskService } from '../../providers/task.service'; +import moment from 'moment'; @Component({ selector: 'task-form', @@ -55,9 +56,9 @@ export class TaskForm { let end_time = '' if(this.action == 'edit'){ - date = task['from_date'].split('T')[0] - start_time = task['from_date'].split('T')[1].split(':').slice(0,2).join(':') - end_time = task['to_date'].split('T')[1].split(':').slice(0,2).join(':') + date = moment(task['from_date']).format('YYYY-MM-DD') + start_time = moment(task['from_date']).format('HH:mm') + end_time = moment(task['to_date']).format('HH:mm') } return this.formBuilder.group({