forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve date parsing #167
Merged
QinHaichen12
merged 1 commit into
AY2425S1-CS2103T-W14-3:master
from
starchypotatocode:branch-update-date
Nov 8, 2024
+60
−13
Merged
Improve date parsing #167
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,19 +33,33 @@ public void isValidDate() { | |
assertFalse(SessionDate.isValidDate("24 September 2024")); // wrong format | ||
assertFalse(SessionDate.isValidDate("Oct 24 2024")); // wrong format | ||
assertFalse(SessionDate.isValidDate("2024 24 Sep")); // wrong format | ||
assertFalse(SessionDate.isValidDate("333 Mar 2024")); // invalid day | ||
assertFalse(SessionDate.isValidDate("30 m 2024")); // invalid month | ||
assertFalse(SessionDate.isValidDate("30 Mar 024")); // invalid year | ||
assertFalse(SessionDate.isValidDate(" Mar 2024")); // missing day | ||
assertFalse(SessionDate.isValidDate("29 2024")); // missing month | ||
assertFalse(SessionDate.isValidDate("30 Mar ")); // missing year | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should there be test cass for invalid dates such as 40 sep 2024 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nvm i saw the prev test |
||
// valid dates | ||
assertTrue(SessionDate.isValidDate("24 Sep 2024")); // valid date | ||
assertTrue(SessionDate.isValidDate("01 Jan 2000")); // valid date | ||
assertTrue(SessionDate.isValidDate("15 Aug 2023")); // valid date | ||
assertTrue(SessionDate.isValidDate("24 Sep 2024")); | ||
assertTrue(SessionDate.isValidDate("01 Jan 2000")); | ||
assertTrue(SessionDate.isValidDate("15 Aug 2023")); | ||
assertTrue(SessionDate.isValidDate("1 Jan 2000")); // no zero-padding | ||
assertTrue(SessionDate.isValidDate("15 aUg 2023")); // wrong case | ||
assertTrue(SessionDate.isValidDate("4 fEB 1989")); //both | ||
} | ||
|
||
@Test | ||
public void equals() { | ||
SessionDate sessionDate = new SessionDate("24 Sep 2024"); | ||
SessionDate sessionDate = new SessionDate("4 Sep 2024"); | ||
|
||
// same values -> returns true | ||
assertTrue(sessionDate.equals(new SessionDate("24 Sep 2024"))); | ||
assertTrue(sessionDate.equals(new SessionDate("4 Sep 2024"))); | ||
|
||
// same after formatting -> returns true | ||
assertTrue(sessionDate.equals(new SessionDate("04 Sep 2024"))); | ||
assertTrue(sessionDate.equals(new SessionDate("4 sep 2024"))); | ||
assertTrue(sessionDate.equals(new SessionDate("4 SeP 2024"))); | ||
|
||
// same object -> returns true | ||
assertTrue(sessionDate.equals(sessionDate)); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does year error mean