[tasque] Fix an issue with DateSeparatedFormatter



commit a6700ebee6d3838cf63b4a6499e69378e5f9bf21
Author: Antonius Riha <antoniusriha gmail com>
Date:   Sun Dec 9 01:05:48 2012 +0100

    Fix an issue with DateSeparatedFormatter

 .../DateFormatters/DateSeparatedFormatter.cs       |    4 ++++
 src/libtasque/TaskParser.cs                        |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/libtasque/DateFormatters/DateSeparatedFormatter.cs b/src/libtasque/DateFormatters/DateSeparatedFormatter.cs
index e7738cc..04da192 100644
--- a/src/libtasque/DateFormatters/DateSeparatedFormatter.cs
+++ b/src/libtasque/DateFormatters/DateSeparatedFormatter.cs
@@ -33,6 +33,10 @@ namespace Tasque.DateFormatters {
 			DateTime dateTime = DateTime.MinValue;
 			try {
 				dateTime = Convert.ToDateTime (match.Groups ["A"].Value);
+				if (!match.Groups ["A1"].Success) {
+					if (dateTime.Month < DateTime.Today.Month)
+						dateTime = dateTime.AddYears (1);
+				}
 			} catch (FormatException) {
 				dateTime = DateTime.MinValue;
 			}
diff --git a/src/libtasque/TaskParser.cs b/src/libtasque/TaskParser.cs
index f905ca8..f1e230b 100644
--- a/src/libtasque/TaskParser.cs
+++ b/src/libtasque/TaskParser.cs
@@ -183,7 +183,7 @@ namespace Tasque {
 				tokens.Add ('A', new TranslatableToken () {
 					Formatter = typeof (DateSeparatedFormatter),
 					Expression = string.Format ("{0}",
-					                            @"[0-9]{1,2}(/|-)[0-9]{1,2}(((/|-)[0-9]{2,4}|/s))?")
+					                            @"[0-9]{1,2}(/|-)[0-9]{1,2}(?<A1>((/|-)[0-9]{2,4}|/s))?")
 				});
 				// Today and Tomorrow
 				tokens.Add ('T', new TranslatableToken () {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]