Skip to content
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

Solution #2176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #2176

wants to merge 1 commit into from

Conversation

izotovav
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on implementing the formatDate function! 🎉 Your solution meets the task requirements and handles the conversion of date formats effectively. While there are some assumptions in your code regarding separators and year formats, these don't impact the core functionality. Keep up the good work, and consider the feedback for future improvements! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +11 to +13
const [fromParts, fromSeparator] = [
fromFormat.slice(0, -1),
fromFormat.slice(-1)[0],

Choose a reason for hiding this comment

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

The assumption that the last element of the fromFormat array is the separator might not always be correct. Consider validating the format or explicitly defining the separator.

fromFormat.slice(0, -1),
fromFormat.slice(-1)[0],
];
const [toParts, toSeparator] = [toFormat.slice(0, -1), toFormat.slice(-1)[0]];

Choose a reason for hiding this comment

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

Similar to the fromFormat, the assumption that the last element of the toFormat array is the separator might not always be correct. Consider validating the format or explicitly defining the separator.

Comment on lines +25 to +27
if (part === 'YY' && dateMap['YYYY']) {
return dateMap['YYYY'].slice(-2);
}

Choose a reason for hiding this comment

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

The conversion from 'YYYY' to 'YY' assumes that 'YYYY' is always present in the fromFormat. Consider adding a check to ensure 'YYYY' exists in dateMap before slicing.

Comment on lines +29 to +33
if (part === 'YYYY' && dateMap['YY']) {
const year = parseInt(dateMap['YY'], 10);

return year < 30 ? `20${dateMap['YY']}` : `19${dateMap['YY']}`;
}

Choose a reason for hiding this comment

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

The conversion from 'YY' to 'YYYY' assumes that 'YY' is always present in the fromFormat. Consider adding a check to ensure 'YY' exists in dateMap before converting.

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.

2 participants