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

add solution #2288

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

add solution #2288

wants to merge 1 commit into from

Conversation

osidanych
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! 🎉 While there are a few areas for improvement, such as making the year conversion logic more flexible and dynamically determining the separator, your code meets the core requirements and functions as expected. Keep up the good work, and consider these suggestions for future enhancements! 😊

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

Comment on lines +12 to +14
const oldSeparator = fromFormat[3];
const oldDate = date.split(oldSeparator);
const newSeparator = toFormat[3];

Choose a reason for hiding this comment

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

The assumption that the separator is always at the fourth position in the format arrays (fromFormat[3] and toFormat[3]) may not be valid. Consider dynamically determining the separator by checking the format strings.

Comment on lines +33 to +36
if (fromFormat[oldYearPosition].length > toFormat[newYearPosition].length) {
oldDate[oldYearPosition] =
oldDate[oldYearPosition][2] + oldDate[oldYearPosition][3];
}

Choose a reason for hiding this comment

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

The logic here assumes that the year is always four characters long in the fromFormat and two characters long in the toFormat. This may not always be the case. Consider adding checks to ensure that the indices used are valid and handle cases where the year length differs.

Comment on lines +38 to +44
if (fromFormat[oldYearPosition].length < toFormat[newYearPosition].length) {
if (+oldDate[oldYearPosition] < 30) {
oldDate[oldYearPosition] = 20 + oldDate[oldYearPosition];
} else {
oldDate[oldYearPosition] = 19 + oldDate[oldYearPosition];
}
}

Choose a reason for hiding this comment

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

The logic for converting two-digit years to four-digit years assumes that any year less than 30 should be prefixed with '20' and others with '19'. This may not be a valid assumption for all use cases. Consider making this logic more flexible or configurable.

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