Skip to content

Commit

Permalink
Merge pull request #79 from Cary-Xx/FixRelease
Browse files Browse the repository at this point in the history
Fix autocomplete bug and date invalidation
  • Loading branch information
Cary-Xx committed Oct 30, 2019
2 parents ff0ae3d + dabf63e commit b0c6f8f
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 59 deletions.
11 changes: 6 additions & 5 deletions src/main/java/seedu/address/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@

/**
* The main entry point to the application.
*
* <p>
* This is a workaround for the following error when MainApp is made the
* entry point of the application:
*
* Error: JavaFX runtime components are missing, and are required to run this application
*
* <p>
* Error: JavaFX runtime components are missing, and are required to run this application
* <p>
* The reason is that MainApp extends Application. In that case, the
* LauncherHelper will check for the javafx.graphics module to be present
* as a named module. We don't use JavaFX via the module system so it can't
* find the javafx.graphics module, and so the launch is aborted.
*
* <p>
* By having a separate main class (Main) that doesn't extend Application
* to be the entry point of the application, we avoid this issue.
*/
public class Main {

public static void main(String[] args) {
Application.launch(MainApp.class, args);
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Optional;
Expand Down Expand Up @@ -112,8 +113,12 @@ public static Currency parseCurrency(ArgumentMultimap argMultimap) throws ParseE
public static Date parseDate(String date) throws ParseException {
requireNonNull(date);
String trimmedDate = date.trim();
if (!Date.isValidDate(trimmedDate)) {
throw new ParseException(Date.MESSAGE_CONSTRAINTS);
try {
if (!Date.isValidDate(trimmedDate)) {
throw new ParseException(Date.MESSAGE_CONSTRAINTS);
}
} catch (DateTimeParseException e) {
throw new ParseException("Input date contains " + e.getCause().getMessage());
}
return new Date(trimmedDate);
}
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/seedu/address/model/expense/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public Date(String date) {
rawValue = date;
value = convertDate(date);
localDate = value.length() > 11
? LocalDate.parse(value, DateTimeFormatter.ofPattern("dd MMM yyyy, H:mma"))
: LocalDate.parse(value, DateTimeFormatter.ofPattern("dd MMM yyyy"));
? LocalDate.parse(value, DateTimeFormatter.ofPattern("dd MMM yyyy, H:mma"))
: LocalDate.parse(value, DateTimeFormatter.ofPattern("dd MMM yyyy"));
}

/**
Expand All @@ -70,11 +70,7 @@ public Date(String rawDate, boolean ifConverted) {
checkArgument(isValidDate(rawDate), MESSAGE_CONSTRAINTS);
rawValue = rawDate;
value = ifConverted ? convertDate(rawDate) : rawDate;
localDate = ifConverted ? value.length() > 11
? LocalDate.parse(value, DateTimeFormatter.ofPattern("dd MMM yyyy, H:mma"))
: LocalDate.parse(value, DateTimeFormatter.ofPattern("dd MMM yyyy"))
: LocalDate.parse(value, DateTimeFormatter.ofPattern("dd/MM/yyyy"));

localDate = null;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ public class SampleDataUtil {
public static Expense[] getSampleExpenses() {
return new Expense[] {
new Expense(new Name("Coffee"), new Amount("$1.8"), new Currency("SGD"),
new Date("1245", false),
new Date("1245"),
getTagSet("food")),
new Expense(new Name("Textbook"), new Amount("$23.50"), new Currency("SGD"),
new Date("930", false),
new Date("930"),
getTagSet("education", "school")),
new Expense(new Name("Earphone"), new Amount("$45"), new Currency("SGD"),
new Date("10/12/2019 1800", false), getTagSet("utility")),
new Date("10/12/2019 1800"), getTagSet("utility")),
new Expense(new Name("Hang out"), new Amount("$50"), new Currency("SGD"),
new Date("15/12/2019 2100", false),
new Date("15/12/2019 2100"),
getTagSet("entertainment")),
new Expense(new Name("Travel to Paris"), new Amount("€850"), new Currency("SGD"),
new Date("25/12/2019 800", false),
new Date("25/12/2019 800"),
getTagSet("travel")),
new Expense(new Name("Gift for duke"), new Amount("$30"), new Currency("SGD"),
new Date("1/11/2019", false),
new Date("1/11/2019"),
getTagSet("relationship"))
};
}
Expand Down
Loading

0 comments on commit b0c6f8f

Please sign in to comment.