Skip to content

Commit

Permalink
fix bags
Browse files Browse the repository at this point in the history
  • Loading branch information
vlavrentieva committed Dec 18, 2024
1 parent a7659d4 commit d43b410
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/formatDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ function formatDate(date, fromFormat, toFormat) {
}
array[indexYear] = year;

const newYY = newFormat.indexOf('YY');
const newFormatYY = newFormat;
const newYY = newFormatYY.indexOf('YY');

newFormat[newYY] = 'YYYY';
newFormatYY[newYY] = 'YYYY';

for (const n of newFormat) {
for (const n of newFormatYY) {
const searchInd = fromFormat.indexOf(n);

newArray.push(array[searchInd]);
Expand All @@ -73,11 +74,12 @@ function formatDate(date, fromFormat, toFormat) {

array[indexYearbig] = yearBig;

const newY = newFormat.indexOf('YYYY');
const newFormatYYYY = newFormat;
const newY = newFormatYYYY.indexOf('YYYY');

newFormat[newY] = 'YY';
newFormatYYYY[newY] = 'YY';

for (const n of newFormat) {
for (const n of newFormatYYYY) {
const searchInd = fromFormat.indexOf(n);

newArray.push(array[searchInd]);
Expand Down

0 comments on commit d43b410

Please sign in to comment.