package seedu.geekeep.model.task;

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

import seedu.geekeep.commons.exceptions.IllegalValueException;

/**
 * Represents the ending date and time of a task. Guarantees: immutable; is valid as declared in
 * {@link #isValidDateTime()}
 */
public class DateTime {

    public static final String MESSAGE_DATETIME_CONSTRAINTS =
            "Date and time format should be in this format: DD-MM-YY HHMM";
    public static final String DATETIME_VALIDATION_REGEX = "\\d{2}-\\d{2}-\\d{2}(\\s{1}\\d{4})?";
    public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd-MM-yy HHmm");

    public final LocalDateTime dateTime;
    public final String value;

    /**
     *  Validates given dateTime.
     */
    public static boolean isValidDateTime(String test) {
        return test.matches(DATETIME_VALIDATION_REGEX);
    }

    public DateTime(String dateTimeString) throws IllegalValueException {
        if (!isValidDateTime(dateTimeString)) {
            throw new IllegalValueException(MESSAGE_DATETIME_CONSTRAINTS);
        }
        this.value = dateTimeString;
        this.dateTime = LocalDateTime.parse(dateTimeString, FORMATTER);
    }

    @Override
    public boolean equals(Object other) {
        return other == this // short circuit if same object
                || (other instanceof DateTime // instanceof handles nulls
                        && this.value.equals(((DateTime) other).value)); // state check
    }

    @Override
    public int hashCode() {
        return dateTime.hashCode();
    }

    @Override
    public String toString() {
        return value;
    }

}

@@ -564,16 +564,155 @@
 %7B4%7D)?%22;%0A
+    public static final String DATETIME_REGEX_WITHOUT_TIME = %22%5C%5Cd%7B2%7D-%5C%5Cd%7B2%7D-%5C%5Cd%7B2%7D%22;%0A    public static final String DEFAULT_TIME = %220000%22;%0A
     publ
@@ -803,16 +803,16 @@
 HHmm%22);%0A
-
 %0A    pub
@@ -1043,24 +1043,157 @@
 EX);%0A    %7D%0A%0A
+    public static boolean isValidDateTimeWithoutTime(String test) %7B%0A        return test.matches(DATETIME_REGEX_WITHOUT_TIME);%0A    %7D%0A%0A
     public D
@@ -1387,16 +1387,16 @@
       %7D%0A
-
         
@@ -1424,16 +1424,150 @@
 String;%0A
+        if (isValidDateTimeWithoutTime(dateTimeString)) %7B%0A            dateTimeString = dateTimeString + %22 %22 + DEFAULT_TIME;%0A        %7D%0A
         

Add default time if time is missing