package tars.model.task;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

import tars.commons.exceptions.IllegalValueException;

/**
 * Represents a Task's datetime in tars.
 */
public class DateTime {
    public static final String MESSAGE_NAME_CONSTRAINTS = "Task datetime should be spaces or alphanumeric characters";

    private LocalDateTime startDate;
    private LocalDateTime endDate;

    /**
     * Validates given task datetime.
     *
     * @throws DateTimeParseException
     *             if given datetime string is invalid.
     * @throws IllegalDateException
     *             end date occurring before start date.
     */
    public DateTime(String startDate, String endDate) throws DateTimeParseException, IllegalDateException {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
        if (startDate != null) {
            this.startDate = LocalDateTime.parse(startDate, formatter);
        }

        this.endDate = LocalDateTime.parse(endDate, formatter);

        if (this.endDate.isBefore(this.startDate)) {
            throw new IllegalDateException("End date should be after start date.");
        }
    }

    public void setStartDate(LocalDateTime startDate) {
        this.startDate = startDate;
    }

    public void setEndDate(LocalDateTime endDate) {
        this.endDate = endDate;
    }

    /**
     * Signals an error caused by end date occurring before start date
     */
    public class IllegalDateException extends IllegalValueException {
        public IllegalDateException(String message) {
            super(message);
        }
    }
}

@@ -464,16 +464,154 @@
 dDate;%0A%0A
+    public String startDateString;%0A    public String endDateString;%0A%0A    /**%0A     * Default constructor%0A     */%0A    public DateTime() %7B%7D%0A%0A
     /**%0A
@@ -642,17 +642,17 @@
 ask date
-t
+T
 ime.%0A   
@@ -721,25 +721,25 @@
 f given date
-t
+T
 ime string i
@@ -1031,26 +1031,129 @@
 (%22dd
--MM-
+/MM/
 yyyy HH
-:
 mm%22);%0A
+%0A        this.endDate = LocalDateTime.parse(endDate, formatter);%0A        this.endDateString = endDate;%0A%0A
     
@@ -1257,23 +1257,16 @@
 r);%0A    
-    %7D%0A%0A
         
@@ -1274,60 +1274,41 @@
 his.
-endDate = LocalDateTime.parse(endDate, formatter);%0A%0A
+startDateString = startDate;%0A    
     
@@ -1352,24 +1352,28 @@
 artDate)) %7B%0A
+    
             
@@ -1448,25 +1448,41 @@
 %22);%0A        
-%7D
+    %7D%0A        %7D%0A%0A
 %0A    %7D%0A%0A    
@@ -1663,24 +1663,236 @@
 ate;%0A    %7D%0A%0A
+    @Override%0A    public String toString() %7B%0A        if (this.startDate == null) %7B%0A            return endDateString;%0A        %7D else %7B%0A            return startDateString + %22 to %22 + endDateString;%0A        %7D%0A    %7D%0A%0A
     /**%0A    

Modify DateTime.java