From 026b13a33fd3ee4c896ccf768e6ebb956e4abb22 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 28 Feb 2017 19:17:03 +0100
Subject: [PATCH] fix on strange french date format (LIH list)

---
 .../smash/appointment/parse/SubjectParser.java    | 15 ++++++++++++++-
 .../parse/LihControlMappingParserTest.java        | 11 +++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java
index e39009ee..cf2d904e 100644
--- a/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java
+++ b/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java
@@ -193,8 +193,21 @@ public abstract class SubjectParser {
 		if (result == null || result.trim().isEmpty()) {
 			result = defaultDateString;
 		}
+		result = fixDate(result);
+		return result;
+	}
+
+	protected String fixDate(String result) {
+		result = result.replaceAll("\\?", "");
+		result = result.replaceAll("jan", "01");
+		result = result.replaceAll("fev", "02");
+		result = result.replaceAll("mar", "03");
+		result = result.replaceAll("avr", "04");
 		result = result.replaceAll("may", "05");
-		result = result.replaceAll("oct", "08");
+		result = result.replaceAll("aou", "08");
+		result = result.replaceAll("cot", "08");
+		result = result.replaceAll("sep", "09");
+		result = result.replaceAll("oct", "10");
 		if (result.indexOf("/") >= 0) {
 			String tmp[] = result.split("/");
 			result = tmp[2] + "-" + tmp[1] + "-" + tmp[0];
diff --git a/appointment-import/src/test/java/smash/appointment/parse/LihControlMappingParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/LihControlMappingParserTest.java
index a7214772..8585f519 100644
--- a/appointment-import/src/test/java/smash/appointment/parse/LihControlMappingParserTest.java
+++ b/appointment-import/src/test/java/smash/appointment/parse/LihControlMappingParserTest.java
@@ -62,4 +62,15 @@ public class LihControlMappingParserTest extends TestBase {
 	}
 
 
+	@Test
+	public void testFixDate() throws Exception {
+		DATE_FORMATTER.parse(processor.fixDate("2016-cot-31"));
+		DATE_FORMATTER.parse(processor.fixDate("25-11-1951"));
+		DATE_FORMATTER.parse(processor.fixDate("1957??-10-25"));
+		DATE_FORMATTER.parse(processor.fixDate("2016?-sep-12"));
+		DATE_FORMATTER.parse(processor.fixDate("2016-aou-26"));
+		DATE_FORMATTER.parse(processor.fixDate("2016-avr-14"));
+		DATE_FORMATTER.parse(processor.fixDate("2016-fev-03"));
+	}
+
 }
-- 
GitLab