Skip to content

Commit

Permalink
fixing for automated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaennchenstruggle committed Oct 25, 2023
1 parent b33f9d4 commit f9e9500
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/default/calendar/calendarutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ const CalendarUtils = {
if (typeof transform === "object") {
if (typeof transform.search !== "undefined" && transform.search !== "" && typeof transform.replace !== "undefined") {
let regParts = transform.search.match(/^\/(.+)\/([gim]*)$/);
var needle = new RegExp(transform.search, "g");
if (regParts) {
// the parsed pattern is a regexp.
needle = new RegExp(regParts[1], regParts[2]);
} else {
needle = new RegExp(transform.search, "g");
}

let replacement = transform.replace;
if (typeof transform.yearmatchgroup !== "undefined" && transform.yearmatchgroup !== "") {
const yearmatch = [...title.matchAll(needle)];
if (yearmatch[0].length >= transform.yearmatchgroup + 1 && yearmatch[0][transform.yearmatchgroup] * 1 >= 1900) {
var calcage = new Date().getFullYear() - yearmatch[0][transform.yearmatchgroup] * 1;
replacement = replacement.replace("$" + transform.yearmatchgroup, calcage);
var searchstr="$" + transform.yearmatchgroup
replacement = replacement.replace(searchstr, calcage);
}
}
transformedTitle = transformedTitle.replace(needle, replacement);
Expand Down

0 comments on commit f9e9500

Please sign in to comment.