added importer for Gewerkschaftshaus erfurt
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -41,6 +41,7 @@ public class Util {
|
||||
public static final String VCALENDAR = "VCALENDAR";
|
||||
|
||||
public static final Pattern GERMAN_DATE_PATTERN = Pattern.compile("^\\D*(\\d\\d?)\\.(\\d\\d?)\\.(\\d{4})\\D");
|
||||
public static final Pattern GERMAN_DATE_WITHOUT_YEAR = Pattern.compile("(\\d\\d?)\\.(\\d\\d?)");
|
||||
public static final Pattern GERMAN_DATE_PATTERN_LONG = Pattern.compile("(\\d\\d?)\\.?\\s*(\\w+)\\s+(\\d{4})\\D");
|
||||
public static final Pattern GERMAN_TIME_PATTERN = Pattern.compile("(\\d\\d?):(\\d\\d?)(:(\\d\\d?))?\\D");
|
||||
private static final Pattern BG_IMAGE_URL = Pattern.compile("background(-image)?:\\surl\\('?([^)]+)'?\\)");
|
||||
@@ -251,4 +252,17 @@ public class Util {
|
||||
return error(e, "Failed to create URL of %s", url);
|
||||
}
|
||||
}
|
||||
|
||||
public static Result<LocalDate> parseGermanDateWithoutYear(String string) {
|
||||
var matcher = GERMAN_DATE_WITHOUT_YEAR.matcher(string);
|
||||
if (matcher.find()){
|
||||
int day = Integer.parseInt(matcher.group(1));
|
||||
int mon = Integer.parseInt(matcher.group(2));
|
||||
var now = LocalDate.now();
|
||||
var date = LocalDate.of(now.getYear(),mon,day);
|
||||
if (date.isBefore(now)) date = date.withYear(now.getYear()+1);
|
||||
return Payload.of(date);
|
||||
}
|
||||
return error("Failed to parse date from %s",string);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user