package seedu.watodo.logic.parser;

import java.util.Date;
import java.util.List;
import java.util.TimeZone;

import com.joestelmach.natty.DateGroup;
import com.joestelmach.natty.Parser;

public class DateTimeParser {
    public static final String MESSAGE_DATETIME_CONSTRAINTS = "Date and time format must be a date/day, time or both";
    public static final Parser DATE_TIME_PARSER = new Parser();

    public DateTimeParser() {
    }

    public static void parse() {
        Parser parser = new Parser();
        List<DateGroup> groups = parser.parse("the day before next thursday");
    for(DateGroup group:groups) {
      List<Date> dates = group.getDates();
      int line = group.getLine();
      int column = group.getPosition();
      String matchingValue = group.getText();
      String syntaxTree = group.getSyntaxTree().toStringTree();
      boolean isRecurreing = group.isRecurring();
      Date recursUntil = group.getRecursUntil();
    }
    }

}

@@ -50,62 +50,12 @@
 til.
-Date;%0Aimport java.util.List;%0Aimport java.util.TimeZone
+List
 ;%0A%0Ai
@@ -135,156 +135,141 @@
 r;%0A%0A
-public class DateTimeParser %7B%0A    public static final String MESSAGE_DATETIME_CONSTRAINTS = %22Date and time format must be a date/day, time or both%22;
+import seedu.watodo.commons.exceptions.IllegalValueException;%0Aimport seedu.watodo.model.task.DateTime;%0A%0Apublic class DateTimeParser %7B
 %0A   
@@ -345,64 +345,69 @@
 lic 
-DateTimeParser() %7B%0A    %7D%0A%0A    public static void parse()
+static String parse(String args) throws IllegalValueException
  %7B%0A 
@@ -493,406 +493,182 @@
 rse(
-%22the day before next thursday%22);%0A    for(DateGroup group:groups) %7B%0A      List%3CDate%3E dates = group.getDates();%0A      int line = group.getLine();%0A      int column = group.getPosition();%0A      String matchingValue = group.getText();%0A      String syntaxTree = group.getSyntaxTree().toStringTree();%0A      boolean isRecurreing = group.isRecurring();%0A
+args);%0A        if (groups.size() == 0) %7B%0A            throw new IllegalValueException(DateTime.MESSAGE_DATETIME_CONSTRAINTS);%0A        %7D%0A 
       
-Date
  re
-cursUntil =
+turn
  group
+s
 .get
-RecursUntil();%0A    %7D
+(0).getText();
 %0A   

add defensive coding in case date is invalid