Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73286e8662 | ||
|
|
95c3f78c68 | ||
|
|
90df505982 | ||
|
|
e8b7114ce8 | ||
|
|
714d9c5544 | ||
|
|
f2ba9f796b | ||
|
|
e025ecc3d4 | ||
|
|
ccd2b9fc44 | ||
|
|
6cb902c499 |
1
AUTHORS
1
AUTHORS
@@ -4,4 +4,5 @@ Principal Author:
|
||||
With thanks to:
|
||||
Eugene Kramer
|
||||
SK
|
||||
Damian Glenny
|
||||
|
||||
|
||||
21
ChangeLog
21
ChangeLog
@@ -1,8 +1,27 @@
|
||||
1.1.0 (?)
|
||||
Version numbers are of the form:
|
||||
|
||||
x.y.z
|
||||
|
||||
where the x represents a major version number, or architecture. The y
|
||||
represents a feature release, and the z represents a patch.
|
||||
|
||||
1.2.0 (?)
|
||||
- Command line specification of alternate .taskrc file
|
||||
|
||||
------ reality -----------------------------------
|
||||
|
||||
1.1.0 (6/7/2008)
|
||||
+ "blanklines" configuration to stop displaying unnecessary white
|
||||
space and thus work better on small-screen devices
|
||||
+ "dateformat" configuration now determines how dates are formatted
|
||||
+ Better formatting of "task tags" output
|
||||
+ http://www.beckingham.net/task.html home page set up
|
||||
+ Added tags to the "task long" report
|
||||
|
||||
1.0.1 (6/4/2008)
|
||||
+ Bug: UUID generator not properly terminating string.
|
||||
+ Bug: srandom/srand not called prior to UUID generation.
|
||||
|
||||
1.0.0 (6/3/2008)
|
||||
+ New movie made, uploaded
|
||||
+ Bug: assertion fails on mobile for t v
|
||||
|
||||
3
NEWS
3
NEWS
@@ -1,4 +1,4 @@
|
||||
Welcome to Task 1.0.0.
|
||||
Welcome to Task 1.1.0.
|
||||
|
||||
Task has been built and tested on the following configurations:
|
||||
|
||||
@@ -8,6 +8,7 @@ Task has been built and tested on the following configurations:
|
||||
- Fedora Core 9
|
||||
- Ubuntu 8 Hardy Heron
|
||||
- Solaris 10
|
||||
- Cygwin 1.5.25-14
|
||||
|
||||
While Task has undergone testing, bugs are sure to remain. If you encounter a
|
||||
bug, please contact me at task@beckingham.net. Here is what you could do, in
|
||||
|
||||
58
TUTORIAL
58
TUTORIAL
@@ -1,4 +1,4 @@
|
||||
Task program tutorial, for version 1.0.0
|
||||
Task program tutorial, for version 1.1.0
|
||||
----------------------------------------
|
||||
|
||||
This guide shows how to quickly set up the task program, and become proficient
|
||||
@@ -21,10 +21,10 @@ Build the task program according to the directions in the INSTALL file. This
|
||||
transcript illustrates a typical installation:
|
||||
|
||||
% ls
|
||||
task-1.0.0.tar.gz
|
||||
% gunzip task-1.0.0.tar.gz
|
||||
% tar xf task-1.0.0.tar
|
||||
% cd task-1.0.0
|
||||
task-1.1.0.tar.gz
|
||||
% gunzip task-1.1.0.tar.gz
|
||||
% tar xf task-1.1.0.tar
|
||||
% cd task-1.1.0
|
||||
% ./configure
|
||||
...
|
||||
% make
|
||||
@@ -554,8 +554,27 @@ Interacting with the Shell
|
||||
background) attributes determines the colors used to represent the task.
|
||||
Valid foreground colors are:
|
||||
|
||||
bold underline bold_underline
|
||||
black bold_black underline_black bold_underline_black
|
||||
red bold_red underline_red bold_underline_red
|
||||
green bold_green underline_green bold_underline_green
|
||||
yellow bold_yellow underline_yellow bold_underline_yellow
|
||||
blue bold_blue underline_blue bold_underline_blue
|
||||
magenta bold_magenta underline_magenta bold_underline_magenta
|
||||
cyan bold_cyan underline_cyan bold_underline_cyan
|
||||
white bold_white underline_white bold_underline_white
|
||||
|
||||
Valid background colors are:
|
||||
|
||||
on_black on_bright_black
|
||||
on_red on_bright_red
|
||||
on_green on_bright_green
|
||||
on_yellow on_bright_yellow
|
||||
on_blue on_bright_blue
|
||||
on_magenta on_bright_magenta
|
||||
on_cyan on_bright_cyan
|
||||
on_white on_bright_white
|
||||
|
||||
Note that these are not just colors, but combinations of colors and
|
||||
attributes.
|
||||
|
||||
@@ -602,6 +621,35 @@ Configuring Task
|
||||
curses Determines whether task uses ncurses to establish the
|
||||
size of the window you are using, for text wrapping.
|
||||
|
||||
blanklines May be "on" or "off". Prevents the display of
|
||||
unnecessary blank lines so that task makes better use
|
||||
screen real estate on small-screened devices.
|
||||
|
||||
dateformat This is a string of characters that define how task
|
||||
formats dates. The default value is:
|
||||
|
||||
m/d/Y
|
||||
|
||||
which means dates look like:
|
||||
|
||||
6/7/2008
|
||||
|
||||
The string should contain the characters:
|
||||
|
||||
m minimal-digit month 1, 12
|
||||
d minimal-digit day 1, 30
|
||||
y two-digit year 08
|
||||
M two-digit month 01, 12
|
||||
D two-digit day 01, 30
|
||||
Y four-digit year 2008
|
||||
|
||||
The string may also contain other characters to act as
|
||||
spacers, or formatting. Other values could include:
|
||||
|
||||
d/m/Y 7/6/2008
|
||||
YMD 20080607
|
||||
m-d-y 6-7-08
|
||||
|
||||
color May be "on" or "off". Determines whether task uses
|
||||
color.
|
||||
|
||||
|
||||
12
adsense.html
Normal file
12
adsense.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<script type="text/javascript"><!--
|
||||
google_ad_client = "pub-9709799404235424";
|
||||
/* Task Main */
|
||||
google_ad_slot = "8660617875";
|
||||
google_ad_width = 120;
|
||||
google_ad_height = 600;
|
||||
//-->
|
||||
</script>
|
||||
<script type="text/javascript"
|
||||
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT(task, 1.0.1, bugs@beckingham.net)
|
||||
AC_INIT(task, 1.1.0, bugs@beckingham.net)
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_SRCDIR([src/task.cpp])
|
||||
AC_CONFIG_HEADER([auto.h])
|
||||
|
||||
71
src/Date.cpp
71
src/Date.cpp
@@ -116,20 +116,77 @@ void Date::toMDY (int& m, int& d, int& y)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Date::toString (std::string& output)
|
||||
{
|
||||
output = toString ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Date::toString (void)
|
||||
std::string Date::toString (const std::string& format /*= "m/d/Y"*/)
|
||||
{
|
||||
/*
|
||||
int m, d, y;
|
||||
toMDY (m, d, y);
|
||||
|
||||
char formatted [11];
|
||||
sprintf (formatted, "%d/%d/%d", m, d, y);
|
||||
return std::string (formatted);
|
||||
*/
|
||||
|
||||
std::string formatted;
|
||||
for (unsigned int i = 0; i < format.length (); ++i)
|
||||
{
|
||||
switch (format[i])
|
||||
{
|
||||
case 'm':
|
||||
{
|
||||
char m[3];
|
||||
sprintf (m, "%d", this->month ());
|
||||
formatted += m;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
{
|
||||
char m[3];
|
||||
sprintf (m, "%02d", this->month ());
|
||||
formatted += m;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
{
|
||||
char d[3];
|
||||
sprintf (d, "%d", this->day ());
|
||||
formatted += d;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
{
|
||||
char d[3];
|
||||
sprintf (d, "%02d", this->day ());
|
||||
formatted += d;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
{
|
||||
char y[3];
|
||||
sprintf (y, "%02d", this->year () % 100);
|
||||
formatted += y;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
{
|
||||
char y[5];
|
||||
sprintf (y, "%d", this->year ());
|
||||
formatted += y;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
formatted += format[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -44,8 +44,7 @@ public:
|
||||
void toEpoch (time_t&);
|
||||
time_t toEpoch ();
|
||||
void toMDY (int&, int&, int&);
|
||||
void toString (std::string&);
|
||||
std::string toString (void);
|
||||
std::string toString (const std::string& format = "m/d/Y");
|
||||
static bool valid (const int, const int, const int);
|
||||
|
||||
static bool leapYear (int);
|
||||
|
||||
158
src/task.cpp
158
src/task.cpp
@@ -285,22 +285,6 @@ int main (int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string epochToString (const std::string& epoch)
|
||||
{
|
||||
char formatted[12] = {0};
|
||||
|
||||
if (epoch.length () && epoch.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (epoch.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
}
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void handleAdd (const TDB& tdb, T& task, Config& conf)
|
||||
{
|
||||
@@ -350,9 +334,9 @@ void handleProjects (const TDB& tdb, T& task, Config& conf)
|
||||
table.addCell (row, 1, i->second);
|
||||
}
|
||||
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< unique.size ()
|
||||
<< (unique.size () == 1 ? " project" : " projects")
|
||||
<< std::endl;
|
||||
@@ -384,11 +368,12 @@ void handleTags (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
// Render a list of tag names from the map.
|
||||
std::cout << optionalBlankLine (conf);
|
||||
foreach (i, unique)
|
||||
std::cout << i->first << std::endl;
|
||||
|
||||
if (unique.size ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< unique.size ()
|
||||
<< (unique.size () == 1 ? " tag" : " tags")
|
||||
<< std::endl;
|
||||
@@ -506,11 +491,7 @@ void handleList (const TDB& tdb, T& task, Config& conf)
|
||||
if (due.length () && due.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
char formatted[12];
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
due = formatted;
|
||||
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
overdue = (dt < now) ? true : false;
|
||||
now += 7 * 86400;
|
||||
@@ -561,9 +542,9 @@ void handleList (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||
<< std::endl;
|
||||
@@ -670,11 +651,7 @@ void handleSmallList (const TDB& tdb, T& task, Config& conf)
|
||||
if (due.length () && due.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
char formatted[12];
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
due = formatted;
|
||||
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
overdue = (dt < now) ? true : false;
|
||||
now += 7 * 86400;
|
||||
@@ -722,9 +699,9 @@ void handleSmallList (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||
<< std::endl;
|
||||
@@ -825,7 +802,7 @@ void handleCompleted (const TDB& tdb, T& task, Config& conf)
|
||||
// All criteria match, so add refTask to the output table.
|
||||
int row = table.addRow ();
|
||||
|
||||
table.addCell (row, 0, end.toString ());
|
||||
table.addCell (row, 0, end.toString (conf.get ("dateformat", "m/d/Y")));
|
||||
table.addCell (row, 1, refTask.getAttribute ("project"));
|
||||
table.addCell (row, 2, refTask.getDescription ());
|
||||
|
||||
@@ -843,9 +820,9 @@ void handleCompleted (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||
<< std::endl;
|
||||
@@ -934,7 +911,10 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
||||
{
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Due");
|
||||
table.addCell (row, 1, epochToString (due));
|
||||
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
table.addCell (row, 1, due);
|
||||
|
||||
if (due.length () && due.find ("/") == std::string::npos)
|
||||
{
|
||||
@@ -959,7 +939,8 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
||||
{
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Start");
|
||||
table.addCell (row, 1, epochToString (refTask.getAttribute ("start")));
|
||||
Date dt (::atoi (refTask.getAttribute ("start").c_str ()));
|
||||
table.addCell (row, 1, dt.toString (conf.get ("dateformat", "m/d/Y")));
|
||||
}
|
||||
|
||||
// end
|
||||
@@ -967,7 +948,8 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
||||
{
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "End");
|
||||
table.addCell (row, 1, epochToString (refTask.getAttribute ("end")));
|
||||
Date dt (::atoi (refTask.getAttribute ("end").c_str ()));
|
||||
table.addCell (row, 1, dt.toString (conf.get ("dateformat", "m/d/Y")));
|
||||
}
|
||||
|
||||
// tags ...
|
||||
@@ -989,7 +971,8 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Entered");
|
||||
std::string entry = epochToString (refTask.getAttribute ("entry"));
|
||||
Date dt (::atoi (refTask.getAttribute ("entry").c_str ()));
|
||||
std::string entry = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
std::string age;
|
||||
std::string created = refTask.getAttribute ("entry");
|
||||
@@ -1004,9 +987,9 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||
<< std::endl;
|
||||
@@ -1048,6 +1031,7 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
||||
table.addColumn ("Start");
|
||||
table.addColumn ("Due");
|
||||
table.addColumn ("Age");
|
||||
table.addColumn ("Tags");
|
||||
table.addColumn ("Description");
|
||||
|
||||
table.setColumnUnderline (0);
|
||||
@@ -1058,6 +1042,7 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
||||
table.setColumnUnderline (5);
|
||||
table.setColumnUnderline (6);
|
||||
table.setColumnUnderline (7);
|
||||
table.setColumnUnderline (8);
|
||||
|
||||
table.setColumnWidth (0, Table::minimum);
|
||||
table.setColumnWidth (1, Table::minimum);
|
||||
@@ -1066,7 +1051,8 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
||||
table.setColumnWidth (4, Table::minimum);
|
||||
table.setColumnWidth (5, Table::minimum);
|
||||
table.setColumnWidth (6, Table::minimum);
|
||||
table.setColumnWidth (7, Table::flexible);
|
||||
table.setColumnWidth (7, Table::minimum);
|
||||
table.setColumnWidth (8, Table::flexible);
|
||||
|
||||
table.setColumnJustification (0, Table::right);
|
||||
table.setColumnJustification (3, Table::right);
|
||||
@@ -1125,22 +1111,14 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
||||
if (started.length () && started.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (started.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
char formatted[12];
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
started = formatted;
|
||||
started = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
}
|
||||
|
||||
std::string entered = refTask.getAttribute ("entry");
|
||||
if (entered.length () && entered.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (entered.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
char formatted[12];
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
entered = formatted;
|
||||
entered = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
}
|
||||
|
||||
// Now format the matching task.
|
||||
@@ -1150,11 +1128,7 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
||||
if (due.length () && due.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
char formatted[12];
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
due = formatted;
|
||||
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
overdue = (dt < now) ? true : false;
|
||||
now += 7 * 86400;
|
||||
@@ -1169,6 +1143,12 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
||||
formatTimeDeltaDays (age, (time_t) (now - dt));
|
||||
}
|
||||
|
||||
// Make a list of tags.
|
||||
std::string tags;
|
||||
std::vector <std::string> all;
|
||||
refTask.getTags (all);
|
||||
join (tags, " ", all);
|
||||
|
||||
// All criteria match, so add refTask to the output table.
|
||||
int row = table.addRow ();
|
||||
table.addCell (row, 0, refTask.getId ());
|
||||
@@ -1178,7 +1158,8 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
||||
table.addCell (row, 4, started);
|
||||
table.addCell (row, 5, due);
|
||||
table.addCell (row, 6, age);
|
||||
table.addCell (row, 7, refTask.getDescription ());
|
||||
table.addCell (row, 7, tags);
|
||||
table.addCell (row, 8, refTask.getDescription ());
|
||||
|
||||
if (conf.get ("color", true))
|
||||
{
|
||||
@@ -1202,9 +1183,9 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||
<< std::endl;
|
||||
@@ -1348,9 +1329,9 @@ void handleReportSummary (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " project" : " projects")
|
||||
<< std::endl;
|
||||
@@ -1490,11 +1471,7 @@ void handleReportNext (const TDB& tdb, T& task, Config& conf)
|
||||
if (due.length () && due.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
char formatted[12];
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
due = formatted;
|
||||
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
overdue = (dt < now) ? true : false;
|
||||
now += 7 * 86400;
|
||||
@@ -1545,9 +1522,9 @@ void handleReportNext (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||
<< std::endl;
|
||||
@@ -1728,7 +1705,7 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
else
|
||||
@@ -1791,7 +1768,7 @@ void handleReportUsage (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
else
|
||||
@@ -1911,8 +1888,8 @@ void handleReportCalendar (const TDB& tdb, T& task, Config& conf)
|
||||
std::cout << Date::monthName (mFrom)
|
||||
<< " "
|
||||
<< yFrom
|
||||
<< std::endl
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< optionalBlankLine (conf)
|
||||
<< renderMonth (mFrom, yFrom, today, pending, conf)
|
||||
<< std::endl;
|
||||
|
||||
@@ -1930,7 +1907,7 @@ void handleReportCalendar (const TDB& tdb, T& task, Config& conf)
|
||||
<< ", "
|
||||
<< Text::colorize (Text::black, Text::on_red, "overdue")
|
||||
<< "."
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
@@ -2006,11 +1983,7 @@ void handleReportActive (const TDB& tdb, T& task, Config& conf)
|
||||
if (due.length () && due.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
char formatted[12];
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
due = formatted;
|
||||
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
Date now;
|
||||
overdue = dt < now ? true : false;
|
||||
@@ -2046,9 +2019,9 @@ void handleReportActive (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||
<< std::endl;
|
||||
@@ -2128,11 +2101,7 @@ void handleReportOverdue (const TDB& tdb, T& task, Config& conf)
|
||||
if (due.length () && due.find ("/") == std::string::npos)
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
int m, d, y;
|
||||
dt.toMDY (m, d, y);
|
||||
char formatted[12];
|
||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
||||
due = formatted;
|
||||
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
// If overdue.
|
||||
if (dt < now)
|
||||
@@ -2162,9 +2131,9 @@ void handleReportOverdue (const TDB& tdb, T& task, Config& conf)
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
std::cout << std::endl
|
||||
std::cout << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl
|
||||
<< optionalBlankLine (conf)
|
||||
<< table.rowCount ()
|
||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||
<< std::endl;
|
||||
@@ -2226,9 +2195,9 @@ void handleReportStats (const TDB& tdb, T& task, Config& conf)
|
||||
if (tasks.size ())
|
||||
{
|
||||
Date e (earliest);
|
||||
std::cout << "Oldest task " << e.toString () << std::endl;
|
||||
std::cout << "Oldest task " << e.toString (conf.get ("dateformat", "m/d/Y")) << std::endl;
|
||||
Date l (latest);
|
||||
std::cout << "Newest task " << l.toString () << std::endl;
|
||||
std::cout << "Newest task " << l.toString (conf.get ("dateformat", "m/d/Y")) << std::endl;
|
||||
std::cout << "Task used for " << formatSeconds (latest - earliest) << std::endl;
|
||||
}
|
||||
|
||||
@@ -2295,7 +2264,7 @@ void handleVersion (Config& conf)
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Copyright (C) 2006 - 2008 Paul Beckingham."
|
||||
std::cout << "Copyright (C) 2006 - 2008 P. Beckingham."
|
||||
<< std::endl
|
||||
<< PACKAGE
|
||||
<< " "
|
||||
@@ -2309,7 +2278,6 @@ void handleVersion (Config& conf)
|
||||
<< "under certain conditions; again, see the COPYING file for details."
|
||||
<< std::endl
|
||||
<< std::endl
|
||||
<< std::endl
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
|
||||
@@ -2515,7 +2483,7 @@ void handleModify (const TDB& tdb, T& task, Config& conf)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void handleColor (Config& conf)
|
||||
{
|
||||
std::cout << std::endl << "Foreground" << std::endl
|
||||
std::cout << optionalBlankLine (conf) << "Foreground" << std::endl
|
||||
<< " "
|
||||
<< Text::colorize (Text::bold, Text::nocolor, "bold") << " "
|
||||
<< Text::colorize (Text::underline, Text::nocolor, "underline") << " "
|
||||
@@ -2586,7 +2554,7 @@ void handleColor (Config& conf)
|
||||
<< " " << Text::colorize (Text::nocolor, Text::on_white, "on_white") << " "
|
||||
<< Text::colorize (Text::nocolor, Text::on_bright_white, "on_bright_white") << std::endl
|
||||
|
||||
<< std::endl;
|
||||
<< optionalBlankLine (conf);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -97,6 +97,7 @@ int autoComplete (const std::string&, const std::vector<std::string>&, std::vect
|
||||
void formatTimeDeltaDays (std::string&, time_t);
|
||||
std::string formatSeconds (time_t);
|
||||
const std::string uuid ();
|
||||
const char* optionalBlankLine (Config&);
|
||||
|
||||
// rules.cpp
|
||||
void initializeColorRules (Config&);
|
||||
|
||||
87
src/tests/date.t.cpp
Normal file
87
src/tests/date.t.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2005 - 2008, Paul Beckingham. All rights reserved.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <Date.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (46);
|
||||
|
||||
Date now;
|
||||
Date yesterday;
|
||||
yesterday -= 1;
|
||||
|
||||
t.ok (yesterday <= now, "yesterday <= now");
|
||||
t.ok (yesterday < now, "yesterday < now");
|
||||
t.notok (yesterday == now, "!(yesterday == now)");
|
||||
t.ok (yesterday != now, "yesterday != now");
|
||||
t.ok (now >= yesterday, "now >= yesterday");
|
||||
t.ok (now > yesterday, "now > yesterday");
|
||||
|
||||
t.ok (Date::valid (2, 29, 2008), "valid: 2/29/2008");
|
||||
t.notok (Date::valid (2, 29, 2007), "invalid: 2/29/2007");
|
||||
|
||||
t.ok (Date::leapYear (2008), "2008 is a leap year");
|
||||
t.notok (Date::leapYear (2007), "2007 is not a leap year");
|
||||
|
||||
t.is (Date::daysInMonth (2, 2008), 29, "29 days in February 2008");
|
||||
t.is (Date::daysInMonth (2, 2007), 28, "28 days in February 2007");
|
||||
|
||||
t.is (Date::monthName (1), "January", "1 = January");
|
||||
t.is (Date::monthName (2), "February", "2 = February");
|
||||
t.is (Date::monthName (3), "March", "3 = March");
|
||||
t.is (Date::monthName (4), "April", "4 = April");
|
||||
t.is (Date::monthName (5), "May", "5 = May");
|
||||
t.is (Date::monthName (6), "June", "6 = June");
|
||||
t.is (Date::monthName (7), "July", "7 = July");
|
||||
t.is (Date::monthName (8), "August", "8 = August");
|
||||
t.is (Date::monthName (9), "September", "9 = September");
|
||||
t.is (Date::monthName (10), "October", "10 = October");
|
||||
t.is (Date::monthName (11), "November", "11 = November");
|
||||
t.is (Date::monthName (12), "December", "12 = December");
|
||||
|
||||
t.is (Date::dayName (0), "Sunday", "0 == Sunday");
|
||||
t.is (Date::dayName (1), "Monday", "1 == Monday");
|
||||
t.is (Date::dayName (2), "Tuesday", "2 == Tuesday");
|
||||
t.is (Date::dayName (3), "Wednesday", "3 == Wednesday");
|
||||
t.is (Date::dayName (4), "Thursday", "4 == Thursday");
|
||||
t.is (Date::dayName (5), "Friday", "5 == Friday");
|
||||
t.is (Date::dayName (6), "Saturday", "6 == Saturday");
|
||||
|
||||
Date happyNewYear (1, 1, 2008);
|
||||
t.is (happyNewYear.dayOfWeek (), 2, "1/1/2008 == Tuesday");
|
||||
t.is (happyNewYear.month (), 1, "1/1/2008 == January");
|
||||
t.is (happyNewYear.day (), 1, "1/1/2008 == 1");
|
||||
t.is (happyNewYear.year (), 2008, "1/1/2008 == 2008");
|
||||
|
||||
t.is (now - yesterday, 1, "today - yesterday == 1");
|
||||
|
||||
t.is (happyNewYear.toString (), "1/1/2008", "toString 1/1/2008");
|
||||
|
||||
int m, d, y;
|
||||
happyNewYear.toMDY (m, d, y);
|
||||
t.is (m, 1, "1/1/2008 == January");
|
||||
t.is (d, 1, "1/1/2008 == 1");
|
||||
t.is (y, 2008, "1/1/2008 == 2008");
|
||||
|
||||
Date epoch (9, 8, 2001);
|
||||
t.ok ((int)epoch.toEpoch () < 1000000000, "9/8/2001 < 1,000,000,000");
|
||||
epoch += 86400;
|
||||
t.ok ((int)epoch.toEpoch () > 1000000000, "9/9/2001 > 1,000,000,000");
|
||||
|
||||
Date fromEpoch (epoch.toEpoch ());
|
||||
t.is (fromEpoch.toString (), epoch.toString (), "ctor (time_t)");
|
||||
|
||||
Date fromString ("1/1/2008");
|
||||
t.is (fromString.month (), 1, "ctor (std::string) -> m");
|
||||
t.is (fromString.day (), 1, "ctor (std::string) -> d");
|
||||
t.is (fromString.year (), 2008, "ctor (std::string) -> y");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
12
src/text.cpp
12
src/text.cpp
@@ -29,6 +29,9 @@
|
||||
#include <string>
|
||||
#include "task.h"
|
||||
|
||||
static const char* newline = "\n";
|
||||
static const char* noline = "";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void wrapText (
|
||||
std::vector <std::string>& lines,
|
||||
@@ -283,3 +286,12 @@ std::string lowerCase (const std::string& input)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const char* optionalBlankLine (Config& conf)
|
||||
{
|
||||
if (conf.get ("blanklines", true) == true)
|
||||
return newline;
|
||||
|
||||
return noline;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user