Skip to content

Commit

Permalink
Temporarily Fixes #82
Browse files Browse the repository at this point in the history
  • Loading branch information
e0003801 committed Oct 26, 2016
1 parent 8063708 commit 2c0982f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/seedu/savvytasker/logic/parser/DateParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import java.util.Date;
import java.util.List;
import java.util.Locale;

import com.joestelmach.natty.DateGroup;

Expand Down Expand Up @@ -65,6 +66,13 @@ public DateParser() {
*/
public InferredDate parseSingle(String input) throws ParseException {
assert input != null;

// Temporary workaround for natty's failure at adapting to locales dd-mm-yyyy, until
// their issue is closed.
if (!Locale.getDefault().equals(Locale.US)) {
input = input.replaceAll("(\\d{1,2})-(\\d{1,2})-((?:\\d\\d){1,2})", "$2-$1-$3");
}

List<DateGroup> dateGroups = this.nattyParser.parse(input);
int totalDates = countDates(dateGroups);

Expand All @@ -75,6 +83,9 @@ public InferredDate parseSingle(String input) throws ParseException {
throw new ParseException(input, "Too many dates entered.");

DateGroup group = dateGroups.get(0);



return new InferredDate(
group.getDates().get(0),
group.isDateInferred(),
Expand Down

0 comments on commit 2c0982f

Please sign in to comment.