Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73286e8662 | ||
|
|
95c3f78c68 | ||
|
|
90df505982 | ||
|
|
e8b7114ce8 | ||
|
|
714d9c5544 | ||
|
|
f2ba9f796b | ||
|
|
e025ecc3d4 | ||
|
|
ccd2b9fc44 | ||
|
|
6cb902c499 | ||
|
|
d216d40121 | ||
|
|
08f4ead97e | ||
|
|
f3de5c0711 |
8
AUTHORS
8
AUTHORS
@@ -1,6 +1,8 @@
|
|||||||
Principal Author
|
Principal Author:
|
||||||
Paul Beckingham, paul@beckingham.net
|
Paul Beckingham, paul@beckingham.net
|
||||||
|
|
||||||
Contributing Authors
|
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
|
- Command line specification of alternate .taskrc file
|
||||||
|
|
||||||
------ reality -----------------------------------
|
------ 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)
|
1.0.0 (6/3/2008)
|
||||||
+ New movie made, uploaded
|
+ New movie made, uploaded
|
||||||
+ Bug: assertion fails on mobile for t v
|
+ 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:
|
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
|
- Fedora Core 9
|
||||||
- Ubuntu 8 Hardy Heron
|
- Ubuntu 8 Hardy Heron
|
||||||
- Solaris 10
|
- Solaris 10
|
||||||
|
- Cygwin 1.5.25-14
|
||||||
|
|
||||||
While Task has undergone testing, bugs are sure to remain. If you encounter a
|
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
|
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
|
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:
|
transcript illustrates a typical installation:
|
||||||
|
|
||||||
% ls
|
% ls
|
||||||
task-1.0.0.tar.gz
|
task-1.1.0.tar.gz
|
||||||
% gunzip task-1.0.0.tar.gz
|
% gunzip task-1.1.0.tar.gz
|
||||||
% tar xf task-1.0.0.tar
|
% tar xf task-1.1.0.tar
|
||||||
% cd task-1.0.0
|
% cd task-1.1.0
|
||||||
% ./configure
|
% ./configure
|
||||||
...
|
...
|
||||||
% make
|
% make
|
||||||
@@ -554,8 +554,27 @@ Interacting with the Shell
|
|||||||
background) attributes determines the colors used to represent the task.
|
background) attributes determines the colors used to represent the task.
|
||||||
Valid foreground colors are:
|
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:
|
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
|
Note that these are not just colors, but combinations of colors and
|
||||||
attributes.
|
attributes.
|
||||||
|
|
||||||
@@ -602,6 +621,35 @@ Configuring Task
|
|||||||
curses Determines whether task uses ncurses to establish the
|
curses Determines whether task uses ncurses to establish the
|
||||||
size of the window you are using, for text wrapping.
|
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 May be "on" or "off". Determines whether task uses
|
||||||
color.
|
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.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ(2.61)
|
AC_PREREQ(2.61)
|
||||||
AC_INIT(task, 1.0.0, bugs@beckingham.net)
|
AC_INIT(task, 1.1.0, bugs@beckingham.net)
|
||||||
AM_INIT_AUTOMAKE
|
AM_INIT_AUTOMAKE
|
||||||
AC_CONFIG_SRCDIR([src/task.cpp])
|
AC_CONFIG_SRCDIR([src/task.cpp])
|
||||||
AC_CONFIG_HEADER([auto.h])
|
AC_CONFIG_HEADER([auto.h])
|
||||||
@@ -35,6 +35,8 @@ AC_FUNC_SELECT_ARGTYPES
|
|||||||
AC_CHECK_FUNCS([select])
|
AC_CHECK_FUNCS([select])
|
||||||
AC_CHECK_FUNC(flock, [AC_DEFINE([HAVE_FLOCK], [1], [Found flock])])
|
AC_CHECK_FUNC(flock, [AC_DEFINE([HAVE_FLOCK], [1], [Found flock])])
|
||||||
AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE([HAVE_UUID], [1], [Found uuid_unparse_lower])])
|
AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE([HAVE_UUID], [1], [Found uuid_unparse_lower])])
|
||||||
|
AC_CHECK_FUNC(random, [AC_DEFINE([HAVE_RANDOM], [1], [Found random])])
|
||||||
|
AC_CHECK_FUNC(srandom, [AC_DEFINE([HAVE_SRANDOM], [1], [Found srandom])])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile src/Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
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)
|
std::string Date::toString (const std::string& format /*= "m/d/Y"*/)
|
||||||
{
|
|
||||||
output = toString ();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
std::string Date::toString (void)
|
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
int m, d, y;
|
int m, d, y;
|
||||||
toMDY (m, d, y);
|
toMDY (m, d, y);
|
||||||
|
|
||||||
char formatted [11];
|
char formatted [11];
|
||||||
sprintf (formatted, "%d/%d/%d", m, d, y);
|
sprintf (formatted, "%d/%d/%d", m, d, y);
|
||||||
return std::string (formatted);
|
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&);
|
void toEpoch (time_t&);
|
||||||
time_t toEpoch ();
|
time_t toEpoch ();
|
||||||
void toMDY (int&, int&, int&);
|
void toMDY (int&, int&, int&);
|
||||||
void toString (std::string&);
|
std::string toString (const std::string& format = "m/d/Y");
|
||||||
std::string toString (void);
|
|
||||||
static bool valid (const int, const int, const int);
|
static bool valid (const int, const int, const int);
|
||||||
|
|
||||||
static bool leapYear (int);
|
static bool leapYear (int);
|
||||||
|
|||||||
165
src/task.cpp
165
src/task.cpp
@@ -207,6 +207,13 @@ int main (int argc, char** argv)
|
|||||||
// TODO Find out what this is, and either promote it to live code, or remove it.
|
// TODO Find out what this is, and either promote it to live code, or remove it.
|
||||||
// std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
|
// std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
|
||||||
|
|
||||||
|
// Set up randomness.
|
||||||
|
#ifdef HAVE_SRANDOM
|
||||||
|
srandom (time (NULL));
|
||||||
|
#else
|
||||||
|
srand (time (NULL));
|
||||||
|
#endif
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Load the config file from the home directory. If the file cannot be
|
// Load the config file from the home directory. If the file cannot be
|
||||||
@@ -278,22 +285,6 @@ int main (int argc, char** argv)
|
|||||||
return 0;
|
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)
|
void handleAdd (const TDB& tdb, T& task, Config& conf)
|
||||||
{
|
{
|
||||||
@@ -343,9 +334,9 @@ void handleProjects (const TDB& tdb, T& task, Config& conf)
|
|||||||
table.addCell (row, 1, i->second);
|
table.addCell (row, 1, i->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< unique.size ()
|
<< unique.size ()
|
||||||
<< (unique.size () == 1 ? " project" : " projects")
|
<< (unique.size () == 1 ? " project" : " projects")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -377,11 +368,12 @@ void handleTags (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render a list of tag names from the map.
|
// Render a list of tag names from the map.
|
||||||
|
std::cout << optionalBlankLine (conf);
|
||||||
foreach (i, unique)
|
foreach (i, unique)
|
||||||
std::cout << i->first << std::endl;
|
std::cout << i->first << std::endl;
|
||||||
|
|
||||||
if (unique.size ())
|
if (unique.size ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< unique.size ()
|
<< unique.size ()
|
||||||
<< (unique.size () == 1 ? " tag" : " tags")
|
<< (unique.size () == 1 ? " tag" : " tags")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -499,11 +491,7 @@ void handleList (const TDB& tdb, T& task, Config& conf)
|
|||||||
if (due.length () && due.find ("/") == std::string::npos)
|
if (due.length () && due.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
Date dt (::atoi (due.c_str ()));
|
Date dt (::atoi (due.c_str ()));
|
||||||
int m, d, y;
|
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
dt.toMDY (m, d, y);
|
|
||||||
char formatted[12];
|
|
||||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
|
||||||
due = formatted;
|
|
||||||
|
|
||||||
overdue = (dt < now) ? true : false;
|
overdue = (dt < now) ? true : false;
|
||||||
now += 7 * 86400;
|
now += 7 * 86400;
|
||||||
@@ -554,9 +542,9 @@ void handleList (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -663,11 +651,7 @@ void handleSmallList (const TDB& tdb, T& task, Config& conf)
|
|||||||
if (due.length () && due.find ("/") == std::string::npos)
|
if (due.length () && due.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
Date dt (::atoi (due.c_str ()));
|
Date dt (::atoi (due.c_str ()));
|
||||||
int m, d, y;
|
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
dt.toMDY (m, d, y);
|
|
||||||
char formatted[12];
|
|
||||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
|
||||||
due = formatted;
|
|
||||||
|
|
||||||
overdue = (dt < now) ? true : false;
|
overdue = (dt < now) ? true : false;
|
||||||
now += 7 * 86400;
|
now += 7 * 86400;
|
||||||
@@ -715,9 +699,9 @@ void handleSmallList (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -818,7 +802,7 @@ void handleCompleted (const TDB& tdb, T& task, Config& conf)
|
|||||||
// All criteria match, so add refTask to the output table.
|
// All criteria match, so add refTask to the output table.
|
||||||
int row = table.addRow ();
|
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, 1, refTask.getAttribute ("project"));
|
||||||
table.addCell (row, 2, refTask.getDescription ());
|
table.addCell (row, 2, refTask.getDescription ());
|
||||||
|
|
||||||
@@ -836,9 +820,9 @@ void handleCompleted (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -927,7 +911,10 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
|||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Due");
|
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)
|
if (due.length () && due.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
@@ -952,7 +939,8 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
|||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Start");
|
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
|
// end
|
||||||
@@ -960,7 +948,8 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
|||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "End");
|
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 ...
|
// tags ...
|
||||||
@@ -982,7 +971,8 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
|||||||
|
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Entered");
|
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 age;
|
||||||
std::string created = refTask.getAttribute ("entry");
|
std::string created = refTask.getAttribute ("entry");
|
||||||
@@ -997,9 +987,9 @@ void handleInfo (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -1041,6 +1031,7 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
table.addColumn ("Start");
|
table.addColumn ("Start");
|
||||||
table.addColumn ("Due");
|
table.addColumn ("Due");
|
||||||
table.addColumn ("Age");
|
table.addColumn ("Age");
|
||||||
|
table.addColumn ("Tags");
|
||||||
table.addColumn ("Description");
|
table.addColumn ("Description");
|
||||||
|
|
||||||
table.setColumnUnderline (0);
|
table.setColumnUnderline (0);
|
||||||
@@ -1051,6 +1042,7 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
table.setColumnUnderline (5);
|
table.setColumnUnderline (5);
|
||||||
table.setColumnUnderline (6);
|
table.setColumnUnderline (6);
|
||||||
table.setColumnUnderline (7);
|
table.setColumnUnderline (7);
|
||||||
|
table.setColumnUnderline (8);
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
table.setColumnWidth (0, Table::minimum);
|
||||||
table.setColumnWidth (1, Table::minimum);
|
table.setColumnWidth (1, Table::minimum);
|
||||||
@@ -1059,7 +1051,8 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
table.setColumnWidth (4, Table::minimum);
|
table.setColumnWidth (4, Table::minimum);
|
||||||
table.setColumnWidth (5, Table::minimum);
|
table.setColumnWidth (5, Table::minimum);
|
||||||
table.setColumnWidth (6, 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 (0, Table::right);
|
||||||
table.setColumnJustification (3, Table::right);
|
table.setColumnJustification (3, Table::right);
|
||||||
@@ -1118,22 +1111,14 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
if (started.length () && started.find ("/") == std::string::npos)
|
if (started.length () && started.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
Date dt (::atoi (started.c_str ()));
|
Date dt (::atoi (started.c_str ()));
|
||||||
int m, d, y;
|
started = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
dt.toMDY (m, d, y);
|
|
||||||
char formatted[12];
|
|
||||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
|
||||||
started = formatted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string entered = refTask.getAttribute ("entry");
|
std::string entered = refTask.getAttribute ("entry");
|
||||||
if (entered.length () && entered.find ("/") == std::string::npos)
|
if (entered.length () && entered.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
Date dt (::atoi (entered.c_str ()));
|
Date dt (::atoi (entered.c_str ()));
|
||||||
int m, d, y;
|
entered = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
dt.toMDY (m, d, y);
|
|
||||||
char formatted[12];
|
|
||||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
|
||||||
entered = formatted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now format the matching task.
|
// Now format the matching task.
|
||||||
@@ -1143,11 +1128,7 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
if (due.length () && due.find ("/") == std::string::npos)
|
if (due.length () && due.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
Date dt (::atoi (due.c_str ()));
|
Date dt (::atoi (due.c_str ()));
|
||||||
int m, d, y;
|
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
dt.toMDY (m, d, y);
|
|
||||||
char formatted[12];
|
|
||||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
|
||||||
due = formatted;
|
|
||||||
|
|
||||||
overdue = (dt < now) ? true : false;
|
overdue = (dt < now) ? true : false;
|
||||||
now += 7 * 86400;
|
now += 7 * 86400;
|
||||||
@@ -1162,6 +1143,12 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
formatTimeDeltaDays (age, (time_t) (now - dt));
|
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.
|
// All criteria match, so add refTask to the output table.
|
||||||
int row = table.addRow ();
|
int row = table.addRow ();
|
||||||
table.addCell (row, 0, refTask.getId ());
|
table.addCell (row, 0, refTask.getId ());
|
||||||
@@ -1171,7 +1158,8 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
table.addCell (row, 4, started);
|
table.addCell (row, 4, started);
|
||||||
table.addCell (row, 5, due);
|
table.addCell (row, 5, due);
|
||||||
table.addCell (row, 6, age);
|
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))
|
if (conf.get ("color", true))
|
||||||
{
|
{
|
||||||
@@ -1195,9 +1183,9 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -1341,9 +1329,9 @@ void handleReportSummary (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " project" : " projects")
|
<< (table.rowCount () == 1 ? " project" : " projects")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -1483,11 +1471,7 @@ void handleReportNext (const TDB& tdb, T& task, Config& conf)
|
|||||||
if (due.length () && due.find ("/") == std::string::npos)
|
if (due.length () && due.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
Date dt (::atoi (due.c_str ()));
|
Date dt (::atoi (due.c_str ()));
|
||||||
int m, d, y;
|
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
dt.toMDY (m, d, y);
|
|
||||||
char formatted[12];
|
|
||||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
|
||||||
due = formatted;
|
|
||||||
|
|
||||||
overdue = (dt < now) ? true : false;
|
overdue = (dt < now) ? true : false;
|
||||||
now += 7 * 86400;
|
now += 7 * 86400;
|
||||||
@@ -1538,9 +1522,9 @@ void handleReportNext (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -1721,7 +1705,7 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else
|
else
|
||||||
@@ -1784,7 +1768,7 @@ void handleReportUsage (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else
|
else
|
||||||
@@ -1904,8 +1888,8 @@ void handleReportCalendar (const TDB& tdb, T& task, Config& conf)
|
|||||||
std::cout << Date::monthName (mFrom)
|
std::cout << Date::monthName (mFrom)
|
||||||
<< " "
|
<< " "
|
||||||
<< yFrom
|
<< yFrom
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< renderMonth (mFrom, yFrom, today, pending, conf)
|
<< renderMonth (mFrom, yFrom, today, pending, conf)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
@@ -1923,7 +1907,7 @@ void handleReportCalendar (const TDB& tdb, T& task, Config& conf)
|
|||||||
<< ", "
|
<< ", "
|
||||||
<< Text::colorize (Text::black, Text::on_red, "overdue")
|
<< Text::colorize (Text::black, Text::on_red, "overdue")
|
||||||
<< "."
|
<< "."
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1999,11 +1983,7 @@ void handleReportActive (const TDB& tdb, T& task, Config& conf)
|
|||||||
if (due.length () && due.find ("/") == std::string::npos)
|
if (due.length () && due.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
Date dt (::atoi (due.c_str ()));
|
Date dt (::atoi (due.c_str ()));
|
||||||
int m, d, y;
|
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
dt.toMDY (m, d, y);
|
|
||||||
char formatted[12];
|
|
||||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
|
||||||
due = formatted;
|
|
||||||
|
|
||||||
Date now;
|
Date now;
|
||||||
overdue = dt < now ? true : false;
|
overdue = dt < now ? true : false;
|
||||||
@@ -2039,9 +2019,9 @@ void handleReportActive (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -2121,11 +2101,7 @@ void handleReportOverdue (const TDB& tdb, T& task, Config& conf)
|
|||||||
if (due.length () && due.find ("/") == std::string::npos)
|
if (due.length () && due.find ("/") == std::string::npos)
|
||||||
{
|
{
|
||||||
Date dt (::atoi (due.c_str ()));
|
Date dt (::atoi (due.c_str ()));
|
||||||
int m, d, y;
|
due = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
dt.toMDY (m, d, y);
|
|
||||||
char formatted[12];
|
|
||||||
sprintf (formatted, "%d/%d/%04d", m, d, y);
|
|
||||||
due = formatted;
|
|
||||||
|
|
||||||
// If overdue.
|
// If overdue.
|
||||||
if (dt < now)
|
if (dt < now)
|
||||||
@@ -2155,9 +2131,9 @@ void handleReportOverdue (const TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
std::cout << std::endl
|
std::cout << optionalBlankLine (conf)
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl
|
<< optionalBlankLine (conf)
|
||||||
<< table.rowCount ()
|
<< table.rowCount ()
|
||||||
<< (table.rowCount () == 1 ? " task" : " tasks")
|
<< (table.rowCount () == 1 ? " task" : " tasks")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@@ -2219,9 +2195,9 @@ void handleReportStats (const TDB& tdb, T& task, Config& conf)
|
|||||||
if (tasks.size ())
|
if (tasks.size ())
|
||||||
{
|
{
|
||||||
Date e (earliest);
|
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);
|
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;
|
std::cout << "Task used for " << formatSeconds (latest - earliest) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2288,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
|
<< std::endl
|
||||||
<< PACKAGE
|
<< PACKAGE
|
||||||
<< " "
|
<< " "
|
||||||
@@ -2302,7 +2278,6 @@ void handleVersion (Config& conf)
|
|||||||
<< "under certain conditions; again, see the COPYING file for details."
|
<< "under certain conditions; again, see the COPYING file for details."
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< std::endl
|
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
@@ -2508,7 +2483,7 @@ void handleModify (const TDB& tdb, T& task, Config& conf)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void handleColor (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::bold, Text::nocolor, "bold") << " "
|
||||||
<< Text::colorize (Text::underline, Text::nocolor, "underline") << " "
|
<< Text::colorize (Text::underline, Text::nocolor, "underline") << " "
|
||||||
@@ -2579,7 +2554,7 @@ void handleColor (Config& conf)
|
|||||||
<< " " << Text::colorize (Text::nocolor, Text::on_white, "on_white") << " "
|
<< " " << Text::colorize (Text::nocolor, Text::on_white, "on_white") << " "
|
||||||
<< Text::colorize (Text::nocolor, Text::on_bright_white, "on_bright_white") << std::endl
|
<< 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);
|
void formatTimeDeltaDays (std::string&, time_t);
|
||||||
std::string formatSeconds (time_t);
|
std::string formatSeconds (time_t);
|
||||||
const std::string uuid ();
|
const std::string uuid ();
|
||||||
|
const char* optionalBlankLine (Config&);
|
||||||
|
|
||||||
// rules.cpp
|
// rules.cpp
|
||||||
void initializeColorRules (Config&);
|
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 <string>
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
|
static const char* newline = "\n";
|
||||||
|
static const char* noline = "";
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void wrapText (
|
void wrapText (
|
||||||
std::vector <std::string>& lines,
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -182,14 +182,18 @@ const std::string uuid ()
|
|||||||
static char randomHexDigit ()
|
static char randomHexDigit ()
|
||||||
{
|
{
|
||||||
static char digits[] = "0123456789abcdef";
|
static char digits[] = "0123456789abcdef";
|
||||||
|
#ifdef HAVE_RANDOM
|
||||||
return digits[random () % 16];
|
return digits[random () % 16];
|
||||||
|
#else
|
||||||
|
return digits[rand () % 16];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const std::string uuid ()
|
const std::string uuid ()
|
||||||
{
|
{
|
||||||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||||
char id [37];
|
char id [48] = {0};
|
||||||
id[0] = randomHexDigit ();
|
id[0] = randomHexDigit ();
|
||||||
id[1] = randomHexDigit ();
|
id[1] = randomHexDigit ();
|
||||||
id[2] = randomHexDigit ();
|
id[2] = randomHexDigit ();
|
||||||
|
|||||||
Reference in New Issue
Block a user