-
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
add task solution #2282
base: master
Are you sure you want to change the base?
add task solution #2282
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 constraints effectively. While there are a few areas for improvement, such as making the century determination logic more flexible and ensuring the separator position is adaptable to different formats, these do not significantly 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! ✨
@@ -8,7 +8,33 @@ | |||
* @returns {string} | |||
*/ | |||
function formatDate(date, fromFormat, toFormat) { | |||
// write code here | |||
const fromSeparator = fromFormat[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.
The assumption that the separator is always at the fourth position in the format array (fromFormat[3]
) might not be valid if the format changes. Ensure that the separator is correctly identified for different formats.
delete dateObj.YY; | ||
} | ||
|
||
const toSeparator = 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.
Similar to the fromFormat, the assumption that the separator is at the fourth position (toFormat[3]
) might not hold true for all formats. Consider a more flexible approach to determine the separator.
if (dateObj.YY && toFormat.includes('YYYY')) { | ||
const year = parseInt(dateObj.YY); | ||
|
||
dateObj.YYYY = year < 30 ? '20' + dateObj.YY : '19' + dateObj.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 logic for determining the century for two-digit years assumes that years less than 30 belong to the 2000s and others to the 1900s. This might not be accurate for all use cases. Consider making this logic more flexible or configurable.
No description provided.