From b5cd5ea18868f08c072f0b71841e73a606054ad4 Mon Sep 17 00:00:00 2001 From: Louis-Claude Canon Date: Mon, 30 Jul 2012 12:38:39 +0200 Subject: [PATCH] Enhancement - Allows relative dates such as "1st" to be entered with capital ("1ST"). --- src/Date.cpp | 14 +++++++------- test/date.t.cpp | 9 ++++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Date.cpp b/src/Date.cpp index 76d521f72..452dc58df 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -992,21 +992,21 @@ bool Date::isRelativeDate (const std::string& input) } // Support "21st" to indicate the next date that is the 21st day. - else if (input.length () <= 4 && - isdigit (input[0])) + else if (in.length () <= 4 && + isdigit (in[0])) { int number; std::string ordinal; - if (isdigit (input[1])) + if (isdigit (in[1])) { - number = atoi (input.substr (0, 2).c_str ()); - ordinal = lowerCase (input.substr (2)); + number = atoi (in.substr (0, 2).c_str ()); + ordinal = lowerCase (in.substr (2)); } else { - number = atoi (input.substr (0, 2).c_str ()); - ordinal = lowerCase (input.substr (1)); + number = atoi (in.substr (0, 2).c_str ()); + ordinal = lowerCase (in.substr (1)); } // Sanity check. diff --git a/test/date.t.cpp b/test/date.t.cpp index a751a856d..cc127a3ca 100644 --- a/test/date.t.cpp +++ b/test/date.t.cpp @@ -35,7 +35,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (174); + UnitTest t (177); try { @@ -342,6 +342,13 @@ int main (int argc, char** argv) Date r16 ("soy"); t.notok (r16.sameYear (now), "soy not in same year as now"); + Date first ("1st"); + t.notok (first.sameMonth (now), "1st not in same month as now"); + t.is (first.day (), 1, "1st day is 1"); + + Date FIRST ("1ST"); + t.ok (FIRST == first, "1st == 1ST"); + Date later ("later"); t.is (later.month (), 1, "later -> m = 1"); t.is (later.day (), 18, "later -> d = 18");