-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
sollution #2226
base: master
Are you sure you want to change the base?
sollution #2226
Conversation
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.
Great job on implementing the formatDate
function! 🎉 Your code meets the task requirements and constraints, effectively handling date format conversions. While there are some areas for improvement, such as making the year conversion logic more flexible and dynamically determining the separator symbol, these are minor issues that don't impact the core functionality. 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! ✨
const getSymbol = fromFormat[3]; | ||
const setSymbol = toFormat[3]; |
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.
Using fromFormat[3]
and toFormat[3]
to determine the symbol for splitting and joining the date parts assumes that the symbol is always at index 3. This might not be reliable if the format arrays do not contain a symbol at that index. Consider dynamically finding the symbol in the format strings.
if (toFormat[findIndex] !== fromFormat[i]) { | ||
if (toFormat[i] === 'YY') { | ||
findIndex = toFormat.indexOf('YY'); | ||
dateIn = dateArr[i].split('').splice(2).join(''); |
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.
The logic here assumes that the year is always represented by two digits and needs to be converted to four digits. Ensure that this logic aligns with the expected input and output formats.
if (dateArr[i] < 30) { | ||
dateIn = dateArr[i].split(''); | ||
dateIn.unshift('20'); | ||
dateIn = dateIn.join(''); | ||
} else if (+dateArr[i] >= 30) { | ||
dateIn = dateArr[i].split(''); | ||
dateIn.unshift('19'); | ||
dateIn = dateIn.join(''); |
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.
The logic for determining whether to prepend '19' or '20' to the year is based on a hardcoded threshold of 30. This may not be accurate for all use cases. Consider making this logic more flexible or configurable.
No description provided.