package seedu.geekeep.model.task;

import seedu.geekeep.commons.exceptions.IllegalValueException;

/**
 * Represents a Person's phone number in the address book. Guarantees: immutable; is valid as declared in
 * {@link #isValidEmail(String)}
 */
public class DateTime {

    public static final String MESSAGE_EMAIL_CONSTRAINTS =
            "Person emails should be 2 alphanumeric/period strings separated by '@'";
    public static final String EMAIL_VALIDATION_REGEX = "[\\w\\.]+@[\\w\\.]+";

    /**
     * Returns if a given string is a valid person email.
     */
    public static boolean isValidEmail(String test) {
        return test.matches(EMAIL_VALIDATION_REGEX);
    }

    public final String value;

    /**
     * Validates given email.
     *
     * @throws IllegalValueException
     *             if given email address string is invalid.
     */
    public DateTime(String email) throws IllegalValueException {
        assert email != null;
        String trimmedEmail = email.trim();
        if (!isValidEmail(trimmedEmail)) {
            throw new IllegalValueException(MESSAGE_EMAIL_CONSTRAINTS);
        }
        this.value = trimmedEmail;
    }

    @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 value.hashCode();
    }

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

}

@@ -28,16 +28,49 @@
 .task;%0A%0A
+%0Aimport java.time.LocalDateTime;%0A
 import s
@@ -147,50 +147,43 @@
 nts 
-a Person's phone number in the address boo
+the starting date and time of a tas
 k. G
@@ -246,28 +246,25 @@
 #isValid
-Email(String
+DateTime(
 )%7D%0A */%0Ap
@@ -286,16 +286,20 @@
 eTime %7B%0A
+    
 %0A    pub
@@ -322,37 +322,40 @@
  String MESSAGE_
-EMAIL
+DATETIME
 _CONSTRAINTS =%0A 
@@ -370,78 +370,74 @@
    %22
-Person emails should be 2 alphanumeric/period strings separated by '@'
+Date and time format should be in this format: YYYY-MM-DDTHH:MM:SS
 %22;%0A 
@@ -466,21 +466,24 @@
  String 
-EMAIL
+DATETIME
 _VALIDAT
@@ -499,95 +499,93 @@
  = %22
-%5B
 %5C%5C
-w%5C%5C.%5D+@%5B%5C%5Cw%5C%5C.%5D+%22;%0A%0A    /**%0A     * Returns if a given string is a valid person email
+d%7B4%7D-%5C%5Cd%7B2%7D-%5C%5Cd%7B2%7DT%5C%5Cd%7B2%7D:%5C%5Cd%7B2%7D:%5C%5Cd%7B2%7D%22;%0A%0A    /**%0A     *  Validates given dateTime
 .%0A  
@@ -623,21 +623,24 @@
  isValid
-Email
+DateTime
 (String 
@@ -675,21 +675,24 @@
 matches(
-EMAIL
+DATETIME
 _VALIDAT
@@ -731,173 +731,32 @@
 nal 
-String value;%0A%0A    /**%0A     * Validates given email.%0A     *%0A     * @throws IllegalValueException%0A     *             if given email address string is invalid.%0A     */
+LocalDateTime dateTime;%0A
 %0A   
@@ -779,21 +779,30 @@
 (String 
-email
+dateTimeString
 ) throws
@@ -827,85 +827,10 @@
 tion
- 
 %7B%0A
-        assert email != null;%0A        String trimmedEmail = email.trim();%0A
     
@@ -835,17 +835,16 @@
       if
- 
 (!isVali
@@ -848,26 +848,31 @@
 alid
-Email(trimmedEmail
+DateTime(dateTimeString
 )) %7B
@@ -928,13 +928,16 @@
 AGE_
-EMAIL
+DATETIME
 _CON
@@ -974,28 +974,54 @@
 his.
-value = trimmedEmail
+dateTime = LocalDateTime.parse(dateTimeString)
 ;%0A  
@@ -1248,20 +1248,23 @@
 && this.
-valu
+dateTim
 e.equals
@@ -1283,20 +1283,23 @@
  other).
-valu
+dateTim
 e)); // 
@@ -1374,20 +1374,23 @@
  return 
-valu
+dateTim
 e.hashCo
@@ -1466,13 +1466,27 @@
 urn 
-value
+dateTime.toString()
 ;%0A  

Refactor Email to DateTime class