Skip to content

added dateEquality#4

Open
chinmay1819 wants to merge 3 commits intoiauroSystems:masterfrom
chinmay1819:dateEquality
Open

added dateEquality#4
chinmay1819 wants to merge 3 commits intoiauroSystems:masterfrom
chinmay1819:dateEquality

Conversation

@chinmay1819
Copy link
Collaborator

added functions to check equality of dates from lhs towards rhs in executer file -> tasks

@chinmay1819
Copy link
Collaborator Author

demo

}


countObliqueIsTwo(str: string): boolean {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create common method for countObliqueIsTwo and countHyphenIsTwo which will be invoked from these 2 methods..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in refactor commit

countObliqueIsTwo(str: string): boolean {
let oblique = '/';
let count = 0;
for (let i = 0; i < str.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove 'for' loop and convert to regEx matching..
(str.match(/\//g) || []).length

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in refactor commit

return false;
}

convertDateObjectToString(dateObject: Date): string {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should accept optional parameter for separator.. default value for separator will be "/" otherwise whatever is passed in parameter

return isoDateRegex.test(str);
}

formatDate(str: any): string {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate method... convertDateObjectToString can be invoked in this method.. remove duplicate code..

}


lessThanCheck(lhs: any, rhs: any): boolean {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change method name... dateComparisonLessThan

return lhsDate.getTime() < rhsDate.getTime();
}

greaterThanCheck(lhs: any, rhs: any): boolean {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change method name... dateComparisonGreaterThan


}

greaterThanDate(lhs: any, rhs: any): boolean {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant code in lessThanDate and greaterThanDate.. convert common code to method and invoke that method

Copy link

@chaitanya-mahamuni chaitanya-mahamuni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve the comments

mayur-yambal
mayur-yambal previously approved these changes Jul 27, 2023
removed for loops and replaced with regex expressions and created a common method countOcurrences which will be invoked by countObliqueIsTwo & countHypenIsTwo method
removed unneccessary comments and console.log statements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants