-
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
Solution #2176
base: master
Are you sure you want to change the base?
Solution #2176
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 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! ✨
const [fromParts, fromSeparator] = [ | ||
fromFormat.slice(0, -1), | ||
fromFormat.slice(-1)[0], |
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 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]]; |
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.
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.
if (part === 'YY' && dateMap['YYYY']) { | ||
return dateMap['YYYY'].slice(-2); | ||
} |
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 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.
if (part === 'YYYY' && dateMap['YY']) { | ||
const year = parseInt(dateMap['YY'], 10); | ||
|
||
return year < 30 ? `20${dateMap['YY']}` : `19${dateMap['YY']}`; | ||
} |
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 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.
No description provided.