Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
tiblazy committed Feb 4, 2025
1 parent f31dcd4 commit dbf6266
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/formatDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
* @returns {string}
*/
function formatDate(date, fromFormat, toFormat) {
const splitFromFormat = fromFormat[3];
const splitFromFormat = fromFormat.find(
(formatMethod) => formatMethod.length === 1,
);
const splitToFormat = toFormat.find(
(formatMethod) => formatMethod.length === 1,
);

const splitDate = date.split(splitFromFormat);

let day = '';
Expand Down Expand Up @@ -46,7 +52,7 @@ function formatDate(date, fromFormat, toFormat) {
}

if (i < toFormat.length - 2) {
newDate += toFormat[3];
newDate += splitToFormat;
}
}

Expand Down

0 comments on commit dbf6266

Please sign in to comment.