diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 86d6beabbf5..93840a23e04 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -99,7 +99,7 @@ public CommandResult execute(Model model) throws CommandException { throw new CommandException(MESSAGE_DUPLICATE_PERSON); } - if (model.hasDateTime(editedPerson)) { + if (!personToEdit.isSameDateTime(editedPerson) && model.hasDateTime(editedPerson)) { throw new CommandException(MESSAGE_DUPLICATE_DATETIME); } diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 9e29e584ab7..7a6fa0fb011 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -103,6 +103,18 @@ public boolean isSamePerson(Person otherPerson) { && otherPerson.getName().equals(getName()); } + /** + * Returns true if both persons have the same set of datetime. + */ + public boolean isSameDateTime(Person otherPerson) { + if (otherPerson == this) { + return true; + } + + return otherPerson != null + && otherPerson.getDateTimes().equals(getDateTimes()); + } + /** * Returns true if both persons have the same identity and data fields. * This defines a stronger notion of equality between two persons.