const months = ["STY", "LUT", "MAR", "KWIE", "MAJ", "CZE", "LIP", "SIE", "WRZ", "PAZ", "LIS", "GRU"]
const options = {
year: "numeric",
month: "long",
day: "numeric"
};
const blocksDate = document.querySelectorAll(".roadmap__time");
blocksDate.forEach((block) => {
const dateString = block.textContent.trim();
const ddmmmyyyy = dateString.split(/[ \/]/);
let dd, mmm, yyyy;
if (ddmmmyyyy.length === 3) {
dd = ddmmmyyyy[0];
mmm = ddmmmyyyy[1]
yyyy = ddmmmyyyy[2];
} else {
dd = 1;
mmm = ddmmmyyyy[0];
yyyy = ddmmmyyyy[1];
}
if (!isNaN(mmm)) mmm = months[+mmm-1]
mmm = mmm.slice(0,3)
console.log(dd, mmm, yyyy);
const dateBlock = new Date(yyyy, months.indexOf(mmm.toUpperCase()), dd, 15, 0, 0, 0);
console.log(dateBlock);
const plDate = dateBlock.toLocaleDateString("pl", options)
console.log(plDate)
});
<span class="roadmap__time">1 Maja, 2022</span>
<span class="roadmap__time">16 czerwca, 2022</span>
<span class="roadmap__time">3 marca, 2022</span>
<span class="roadmap__time">3 lipca 2022</span>
<span class="roadmap__time">9 lipca 2021</span>
<time class="roadmap__time"> 15/07/2022</time>
<span class="roadmap__time">marca/2022</span>
<span class="roadmap__time">Lipca/2022</span>
<span class="roadmap__time">05/2022</span>
<span class="roadmap__time">06/2022</span>
<span class="roadmap__time">lipca, 2021</span>
<span class="roadmap__time">lipca 2021</span>