diff --git a/AUTHORS b/AUTHORS index 11bc443a1..24e09284a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -50,4 +50,5 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges Rich Mintz Seneca Cunningham Dirk Deimeke + Michelle Crane diff --git a/ChangeLog b/ChangeLog index 866e20c17..bffad8d25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,8 @@ for which there are pending tasks (thanks to Dirk Deimeke). + Fixed bug #414, that caused filtering on the presence or absence of tags containing Unicode characters to fail (thanks to Michal Josífko). + + Fixed bug #416, which caused sorting on a date to fail if the year was not + included in the dateformat (thanks to Michelle Crane). ------ old releases ------------------------------ diff --git a/src/Date.cpp b/src/Date.cpp index b3a187fa9..83a168a42 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -86,7 +86,7 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */) { int month = 0; int day = 0; - int year = 0; + int year = -1; // So we can check later. int hour = 0; int minute = 0; int second = 0; @@ -332,6 +332,14 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */) } } + // Default the year to the current year, for formats that lack Y/y. + if (year == -1) + { + time_t now = time (NULL); + struct tm* default_year = localtime (&now); + year = default_year->tm_year + 1900; + } + if (i < mdy.length ()) throw std::string ("\"") + mdy + "\" is not a valid date in " + format + " format."; diff --git a/src/tests/datesort.t b/src/tests/datesort.t new file mode 100755 index 000000000..afe736400 --- /dev/null +++ b/src/tests/datesort.t @@ -0,0 +1,70 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2010, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 6; + +# Create the rc file. +if (open my $fh, '>', 'datesort.rc') +{ + print $fh "data.location=.\n", + "dateformat=YMD\n", + "report.small_list.description=Small list\n", + "report.small_list.columns=due,description\n", + "report.small_list.labels=Due,Description\n", + "report.small_list.sort=due+\n", + "report.small_list.filter=status:pending\n", + "report.small_list.dateformat=MD\n"; + + close $fh; + ok (-r 'datesort.rc', 'Created datesort.rc'); +} + +qx{../task rc:datesort.rc add two due:20100201}; +qx{../task rc:datesort.rc add one due:20100101}; +qx{../task rc:datesort.rc add three due:20100301}; + +my $output = qx{../task rc:datesort.rc small_list}; +like ($output, qr/one.+two.+three/ms, 'Sorting by due+ with format MD works'); + +$output = qx{../task rc:datesort.rc rc.report.small_list.sort=due- small_list}; +like ($output, qr/three.+two.+one/ms, 'Sorting by due- with format MD works'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'datesort.rc'; +ok (!-r 'datesort.rc', 'Removed datesort.rc'); + +exit 0; +