package tars.model.task;

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

/**
 * 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 dateTime;

    /**
     * Validates given task datetime.
     *
     * @throws DateTimeParseException if given datetime string is invalid.
     */
    public DateTime(String dateTime) throws DateTimeParseException{
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
        this.dateTime = LocalDateTime.parse(dateTime, formatter);
    }

    public LocalDateTime getDateTime() {
        return dateTime;
    }

    public void setDateTime(LocalDateTime dateTime) {
        this.dateTime = dateTime;
    }
    
}

@@ -143,16 +143,71 @@
 ption;%0A%0A
+import tars.commons.exceptions.IllegalValueException;%0A%0A
 /**%0A * R
@@ -417,23 +417,59 @@
 ateTime 
-dateTim
+startDate;%0A    private LocalDateTime endDat
 e;%0A%0A    
@@ -554,16 +554,35 @@
 xception
+%0A     *            
  if give
@@ -611,16 +611,109 @@
 nvalid.%0A
+     * @throws IllegalDateException%0A     *             end date occurring before start date.%0A
      */%0A
@@ -739,23 +739,40 @@
 (String 
-dateTim
+startDate, String endDat
 e) throw
@@ -795,16 +795,39 @@
 xception
+, IllegalDateException 
 %7B%0A      
@@ -911,36 +911,74 @@
 %22);%0A        
-this.dateTim
+if (startDate != null) %7B%0A            this.startDat
 e = LocalDat
@@ -989,23 +989,24 @@
 e.parse(
-dateTim
+startDat
 e, forma
@@ -1020,48 +1020,129 @@
     
-%7D%0A%0A    public LocalDateTime getDateTime(
+    %7D%0A%0A        this.endDate = LocalDateTime.parse(endDate, formatter);%0A%0A        if (this.endDate.isBefore(this.startDate)
 ) %7B%0A
@@ -1153,24 +1153,93 @@
     
+   
-return dateTime;
+ throw new IllegalDateException(%22End date should be after start date.%22);%0A        %7D
 %0A   
@@ -1261,23 +1261,24 @@
 void set
-DateTim
+StartDat
 e(LocalD
@@ -1289,54 +1289,398 @@
 ime 
-dateTime) %7B%0A        this.dateTime = dateTime;%0A
+startDate) %7B%0A        this.startDate = startDate;%0A    %7D%0A%0A    public void setEndDate(LocalDateTime endDate) %7B%0A        this.endDate = endDate;%0A    %7D%0A%0A    /**%0A     * Signals an error caused by end date occurring before start date%0A     */%0A    public class IllegalDateException extends IllegalValueException %7B%0A        public IllegalDateException(String message) %7B%0A            super(message);%0A    
     
@@ -1685,11 +1685,12 @@
   %7D%0A    
+%7D
 %0A%7D%0A

Modify DateTime