mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Duration
- Renamed Duration object to OldDuration so that the two implementations can coexist in a binary.
This commit is contained in:
parent
9bfe40fac7
commit
18f03c25b4
20 changed files with 566 additions and 566 deletions
|
@ -1397,7 +1397,7 @@ bool A3::is_attmod (Nibbler& n, Arg& arg)
|
|||
n.getQuoted ('\'', value) ||
|
||||
// TODO Need more things recognized before it falls through to getUntilEOS.
|
||||
// n.getDate (context.config.get ("dateformat"), date) ||
|
||||
// need Duration too.
|
||||
// need OldDuration too.
|
||||
n.getUntilWS (value) ||
|
||||
n.getName (value) ||
|
||||
n.getUntilEOS (value) || // Redundant?
|
||||
|
@ -1599,7 +1599,7 @@ bool A3::is_duration (Nibbler& n, std::string& result)
|
|||
|
||||
double d;
|
||||
std::string unit;
|
||||
std::vector <std::string> units = Duration::get_units ();
|
||||
std::vector <std::string> units = OldDuration::get_units ();
|
||||
|
||||
if (n.getUnsignedNumber (d) &&
|
||||
n.getOneOf (units, unit))
|
||||
|
|
24
src/E9.cpp
24
src/E9.cpp
|
@ -179,9 +179,9 @@ void E9::eval (const Task& task, std::vector <Arg>& value_stack)
|
|||
if (Date::valid (operand._raw, _dateformat))
|
||||
operand._value = Date (operand._raw, _dateformat).toEpochString ();
|
||||
|
||||
else if (Duration::valid (operand._raw))
|
||||
else if (OldDuration::valid (operand._raw))
|
||||
{
|
||||
Duration dur (operand._raw);
|
||||
OldDuration dur (operand._raw);
|
||||
Date now;
|
||||
now += (int)(time_t) dur;
|
||||
operand._value = now.toEpochString ();
|
||||
|
@ -196,7 +196,7 @@ void E9::eval (const Task& task, std::vector <Arg>& value_stack)
|
|||
{
|
||||
operand._category = Arg::cat_literal;
|
||||
operand._value = (operand._raw != "")
|
||||
? (std::string)Duration (operand._raw)
|
||||
? (std::string)OldDuration (operand._raw)
|
||||
: "";
|
||||
}
|
||||
else
|
||||
|
@ -343,8 +343,8 @@ void E9::operator_lt (Arg& result, Arg& left, Arg& right)
|
|||
result._value = "false";
|
||||
else
|
||||
{
|
||||
Duration left_duration (left._value);
|
||||
Duration right_duration (right._value);
|
||||
OldDuration left_duration (left._value);
|
||||
OldDuration right_duration (right._value);
|
||||
|
||||
result._value = (left_duration < right_duration)
|
||||
? "true"
|
||||
|
@ -408,8 +408,8 @@ void E9::operator_lte (Arg& result, Arg& left, Arg& right)
|
|||
result._value = "false";
|
||||
else
|
||||
{
|
||||
Duration left_duration (left._value);
|
||||
Duration right_duration (right._value);
|
||||
OldDuration left_duration (left._value);
|
||||
OldDuration right_duration (right._value);
|
||||
|
||||
result._value = (left_duration <= right_duration)
|
||||
? "true"
|
||||
|
@ -473,8 +473,8 @@ void E9::operator_gte (Arg& result, Arg& left, Arg& right)
|
|||
result._value = "false";
|
||||
else
|
||||
{
|
||||
Duration left_duration (left._value);
|
||||
Duration right_duration (right._value);
|
||||
OldDuration left_duration (left._value);
|
||||
OldDuration right_duration (right._value);
|
||||
|
||||
result._value = (left_duration >= right_duration)
|
||||
? "true"
|
||||
|
@ -537,8 +537,8 @@ void E9::operator_gt (Arg& result, Arg& left, Arg& right)
|
|||
result._value = "false";
|
||||
else
|
||||
{
|
||||
Duration left_duration (left._value);
|
||||
Duration right_duration (right._value);
|
||||
OldDuration left_duration (left._value);
|
||||
OldDuration right_duration (right._value);
|
||||
|
||||
result._value = result._value = (left_duration > right_duration)
|
||||
? "true"
|
||||
|
@ -807,7 +807,7 @@ const Arg E9::coerce (const Arg& input, const Arg::type type)
|
|||
}
|
||||
|
||||
// TODO Date
|
||||
// TODO Duration
|
||||
// TODO OldDuration
|
||||
else
|
||||
{
|
||||
result = input;
|
||||
|
|
|
@ -98,21 +98,21 @@ static const char* durations[] =
|
|||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration ()
|
||||
OldDuration::OldDuration ()
|
||||
: _secs (0)
|
||||
, _negative (false)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration (const Duration& other)
|
||||
OldDuration::OldDuration (const OldDuration& other)
|
||||
{
|
||||
_secs = other._secs;
|
||||
_negative = other._negative;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration (time_t input)
|
||||
OldDuration::OldDuration (time_t input)
|
||||
{
|
||||
if (input < 0)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ Duration::Duration (time_t input)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration (const std::string& input)
|
||||
OldDuration::OldDuration (const std::string& input)
|
||||
: _secs (0)
|
||||
, _negative (false)
|
||||
{
|
||||
|
@ -146,13 +146,13 @@ Duration::Duration (const std::string& input)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::operator time_t () const
|
||||
OldDuration::operator time_t () const
|
||||
{
|
||||
return _secs;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::operator std::string () const
|
||||
OldDuration::operator std::string () const
|
||||
{
|
||||
std::stringstream s;
|
||||
s << (_negative ? - (long) _secs : (long) _secs);
|
||||
|
@ -160,7 +160,7 @@ Duration::operator std::string () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration& Duration::operator= (const Duration& other)
|
||||
OldDuration& OldDuration::operator= (const OldDuration& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
|
@ -172,14 +172,14 @@ Duration& Duration::operator= (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration Duration::operator- (const Duration& other)
|
||||
OldDuration OldDuration::operator- (const OldDuration& other)
|
||||
{
|
||||
int left = _secs * ( _negative ? -1 : 1);
|
||||
int right = other._secs * (other._negative ? -1 : 1);
|
||||
|
||||
left -= right;
|
||||
|
||||
Duration result;
|
||||
OldDuration result;
|
||||
result._secs = abs (left);
|
||||
result._negative = left < 0;
|
||||
|
||||
|
@ -187,14 +187,14 @@ Duration Duration::operator- (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration Duration::operator+ (const Duration& other)
|
||||
OldDuration OldDuration::operator+ (const OldDuration& other)
|
||||
{
|
||||
int left = _secs * ( _negative ? -1 : 1);
|
||||
int right = other._secs * (other._negative ? -1 : 1);
|
||||
|
||||
left += right;
|
||||
|
||||
Duration result;
|
||||
OldDuration result;
|
||||
result._secs = abs (left);
|
||||
result._negative = left < 0;
|
||||
|
||||
|
@ -202,7 +202,7 @@ Duration Duration::operator+ (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration& Duration::operator-= (const Duration& other)
|
||||
OldDuration& OldDuration::operator-= (const OldDuration& other)
|
||||
{
|
||||
int left = _secs * ( _negative ? -1 : 1);
|
||||
int right = other._secs * (other._negative ? -1 : 1);
|
||||
|
@ -216,7 +216,7 @@ Duration& Duration::operator-= (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration& Duration::operator+= (const Duration& other)
|
||||
OldDuration& OldDuration::operator+= (const OldDuration& other)
|
||||
{
|
||||
int left = _secs * ( _negative ? -1 : 1);
|
||||
int right = other._secs * (other._negative ? -1 : 1);
|
||||
|
@ -230,7 +230,7 @@ Duration& Duration::operator+= (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Duration::format () const
|
||||
std::string OldDuration::format () const
|
||||
{
|
||||
char formatted[24];
|
||||
float days = (float) _secs / 86400.0;
|
||||
|
@ -268,7 +268,7 @@ std::string Duration::format () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Duration::formatCompact () const
|
||||
std::string OldDuration::formatCompact () const
|
||||
{
|
||||
char formatted[24];
|
||||
float days = (float) _secs / 86400.0;
|
||||
|
@ -286,7 +286,7 @@ std::string Duration::formatCompact () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Duration::formatPrecise () const
|
||||
std::string OldDuration::formatPrecise () const
|
||||
{
|
||||
char formatted[24];
|
||||
|
||||
|
@ -303,7 +303,7 @@ std::string Duration::formatPrecise () const
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Duration::formatSeconds () const
|
||||
std::string OldDuration::formatSeconds () const
|
||||
{
|
||||
char formatted[24];
|
||||
sprintf (formatted, "%s%llusec", (_negative ? "-" : ""), (unsigned long long)_secs);
|
||||
|
@ -311,7 +311,7 @@ std::string Duration::formatSeconds () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator< (const Duration& other)
|
||||
bool OldDuration::operator< (const OldDuration& other)
|
||||
{
|
||||
long left = (long) ( _negative ? -_secs : _secs);
|
||||
long right = (long) (other._negative ? -other._secs : other._secs);
|
||||
|
@ -320,7 +320,7 @@ bool Duration::operator< (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator<= (const Duration& other)
|
||||
bool OldDuration::operator<= (const OldDuration& other)
|
||||
{
|
||||
long left = (long) ( _negative ? -_secs : _secs);
|
||||
long right = (long) (other._negative ? -other._secs : other._secs);
|
||||
|
@ -329,7 +329,7 @@ bool Duration::operator<= (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator> (const Duration& other)
|
||||
bool OldDuration::operator> (const OldDuration& other)
|
||||
{
|
||||
long left = (long) ( _negative ? -_secs : _secs);
|
||||
long right = (long) (other._negative ? -other._secs : other._secs);
|
||||
|
@ -338,7 +338,7 @@ bool Duration::operator> (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator>= (const Duration& other)
|
||||
bool OldDuration::operator>= (const OldDuration& other)
|
||||
{
|
||||
long left = (long) ( _negative ? -_secs : _secs);
|
||||
long right = (long) (other._negative ? -other._secs : other._secs);
|
||||
|
@ -347,18 +347,18 @@ bool Duration::operator>= (const Duration& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::~Duration ()
|
||||
OldDuration::~OldDuration ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::negative () const
|
||||
bool OldDuration::negative () const
|
||||
{
|
||||
return _negative;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::valid (const std::string& input)
|
||||
bool OldDuration::valid (const std::string& input)
|
||||
{
|
||||
std::string lower_input = lowerCase (input);
|
||||
|
||||
|
@ -396,7 +396,7 @@ bool Duration::valid (const std::string& input)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Duration::parse (const std::string& input)
|
||||
void OldDuration::parse (const std::string& input)
|
||||
{
|
||||
std::string lower_input = lowerCase (input);
|
||||
|
||||
|
@ -508,7 +508,7 @@ void Duration::parse (const std::string& input)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::vector <std::string> Duration::get_units ()
|
||||
const std::vector <std::string> OldDuration::get_units ()
|
||||
{
|
||||
std::vector <std::string> units;
|
||||
for (unsigned int i = 0; i < NUM_DURATIONS; ++i)
|
||||
|
|
|
@ -25,30 +25,30 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDED_DURATION
|
||||
#define INCLUDED_DURATION
|
||||
#ifndef INCLUDED_OLD_DURATION
|
||||
#define INCLUDED_OLD_DURATION
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
class Duration
|
||||
class OldDuration
|
||||
{
|
||||
public:
|
||||
Duration (); // Default constructor
|
||||
Duration (const Duration&); // Copy constructor
|
||||
Duration (time_t); // Constructor
|
||||
Duration (const std::string&); // Parse
|
||||
bool operator< (const Duration&);
|
||||
bool operator<= (const Duration&);
|
||||
bool operator> (const Duration&);
|
||||
bool operator>= (const Duration&);
|
||||
Duration& operator= (const Duration&);
|
||||
Duration operator- (const Duration&);
|
||||
Duration operator+ (const Duration&);
|
||||
Duration& operator-= (const Duration&);
|
||||
Duration& operator+= (const Duration&);
|
||||
~Duration (); // Destructor
|
||||
OldDuration (); // Default constructor
|
||||
OldDuration (const OldDuration&); // Copy constructor
|
||||
OldDuration (time_t); // Constructor
|
||||
OldDuration (const std::string&); // Parse
|
||||
bool operator< (const OldDuration&);
|
||||
bool operator<= (const OldDuration&);
|
||||
bool operator> (const OldDuration&);
|
||||
bool operator>= (const OldDuration&);
|
||||
OldDuration& operator= (const OldDuration&);
|
||||
OldDuration operator- (const OldDuration&);
|
||||
OldDuration operator+ (const OldDuration&);
|
||||
OldDuration& operator-= (const OldDuration&);
|
||||
OldDuration& operator+= (const OldDuration&);
|
||||
~OldDuration (); // Destructor
|
||||
|
||||
operator time_t () const;
|
||||
operator std::string () const;
|
||||
|
|
|
@ -1287,7 +1287,7 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
// Recur durations must be valid.
|
||||
if (has ("recur"))
|
||||
{
|
||||
Duration d;
|
||||
OldDuration d;
|
||||
if (! d.valid (get ("recur")))
|
||||
throw std::string (format (STRING_TASK_VALID_RECUR, get ("recur")));
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ ColumnDate::ColumnDate ()
|
|||
_examples.push_back (format (now.toJulian (), 13, 12));
|
||||
_examples.push_back (now.toEpochString ());
|
||||
_examples.push_back (now.toISO ());
|
||||
_examples.push_back (Duration (Date () - now).formatCompact ());
|
||||
_examples.push_back (OldDuration (Date () - now).formatCompact ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -99,7 +99,7 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim
|
|||
{
|
||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
||||
Date now;
|
||||
minimum = maximum = Duration (now - date).format ().length ();
|
||||
minimum = maximum = OldDuration (now - date).format ().length ();
|
||||
}
|
||||
else if (_style == "julian")
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim
|
|||
else if (_style == "age")
|
||||
{
|
||||
Date now;
|
||||
minimum = maximum = Duration (now - date).formatCompact ().length ();
|
||||
minimum = maximum = OldDuration (now - date).formatCompact ().length ();
|
||||
}
|
||||
else
|
||||
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||
|
@ -159,7 +159,7 @@ void ColumnDate::render (
|
|||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (
|
||||
Duration (now - date).format (), width)));
|
||||
OldDuration (now - date).format (), width)));
|
||||
}
|
||||
else if (_style == "julian")
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ void ColumnDate::render (
|
|||
lines.push_back (
|
||||
color.colorize (
|
||||
leftJustify (
|
||||
Duration (now - date).formatCompact (), width)));
|
||||
OldDuration (now - date).formatCompact (), width)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ ColumnDue::ColumnDue ()
|
|||
|
||||
Date now;
|
||||
now += 125;
|
||||
_examples.push_back (Duration (now - Date ()).formatCompact ());
|
||||
_examples.push_back (OldDuration (now - Date ()).formatCompact ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -81,7 +81,7 @@ void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maxi
|
|||
if (_style == "default" ||
|
||||
_style == "duration")
|
||||
{
|
||||
minimum = maximum = Duration (task.get ("recur")).formatCompact ().length ();
|
||||
minimum = maximum = OldDuration (task.get ("recur")).formatCompact ().length ();
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ void ColumnRecur::render (
|
|||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (
|
||||
Duration (task.get ("recur")).formatCompact (),
|
||||
OldDuration (task.get ("recur")).formatCompact (),
|
||||
width)));
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
|
|
|
@ -45,7 +45,7 @@ ColumnScheduled::ColumnScheduled ()
|
|||
|
||||
Date now;
|
||||
now += 125;
|
||||
_examples.push_back (Duration (now - Date ()).formatCompact ());
|
||||
_examples.push_back (OldDuration (now - Date ()).formatCompact ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -102,7 +102,7 @@ void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximu
|
|||
}
|
||||
else if (_type == "duration")
|
||||
{
|
||||
minimum = maximum = utf8_width (Duration (value).formatCompact ());
|
||||
minimum = maximum = utf8_width (OldDuration (value).formatCompact ());
|
||||
}
|
||||
else if (_type == "string")
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ void ColumnUDA::render (
|
|||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (
|
||||
Duration (value).formatCompact (),
|
||||
OldDuration (value).formatCompact (),
|
||||
width)));
|
||||
}
|
||||
else if (_type == "string")
|
||||
|
|
|
@ -933,7 +933,7 @@ void Chart::calculateRates (std::vector <time_t>& sequence)
|
|||
int remaining_days = (int) (current_pending / (fix_rate - find_rate));
|
||||
|
||||
Date now;
|
||||
Duration delta (remaining_days * 86400);
|
||||
OldDuration delta (remaining_days * 86400);
|
||||
now += delta;
|
||||
|
||||
completion = now.toString (context.config.get ("dateformat"))
|
||||
|
|
|
@ -149,7 +149,7 @@ std::string CmdEdit::formatDuration (
|
|||
std::string value = task.get (attribute);
|
||||
if (value.length ())
|
||||
{
|
||||
Duration dur (value);
|
||||
OldDuration dur (value);
|
||||
value = dur.formatSeconds ();
|
||||
}
|
||||
|
||||
|
@ -534,7 +534,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
|||
{
|
||||
if (value != "")
|
||||
{
|
||||
Duration d;
|
||||
OldDuration d;
|
||||
if (d.valid (value))
|
||||
{
|
||||
context.footnote (STRING_EDIT_RECUR_MOD);
|
||||
|
@ -710,7 +710,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
|||
}
|
||||
else if (type == "duration")
|
||||
{
|
||||
Duration d (value);
|
||||
OldDuration d (value);
|
||||
task.set (col->first, (time_t) d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ int CmdInfo::execute (std::string& output)
|
|||
if (created.length ())
|
||||
{
|
||||
Date dt (strtol (created.c_str (), NULL, 10));
|
||||
age = Duration (now - dt).format ();
|
||||
age = OldDuration (now - dt).format ();
|
||||
}
|
||||
|
||||
view.set (row, 1, entry + " (" + age + ")");
|
||||
|
@ -311,7 +311,7 @@ int CmdInfo::execute (std::string& output)
|
|||
|
||||
Date mod (task->get_date ("modified"));
|
||||
|
||||
std::string age = Duration (now - mod).format ();
|
||||
std::string age = OldDuration (now - mod).format ();
|
||||
view.set (row, 1, Date (task->get_date ("modified")).toString (dateformat) +
|
||||
" (" + age + ")");
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ int CmdInfo::execute (std::string& output)
|
|||
if (type == "date")
|
||||
value = Date (value).toString (dateformat);
|
||||
else if (type == "duration")
|
||||
value = Duration (value).formatCompact ();
|
||||
value = OldDuration (value).formatCompact ();
|
||||
|
||||
view.set (row, 1, value);
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ int CmdInfo::execute (std::string& output)
|
|||
{
|
||||
row = journal.addRow ();
|
||||
journal.set (row, 0, STRING_CMD_INFO_TOTAL_ACTIVE);
|
||||
journal.set (row, 1, Duration (total_time).formatPrecise (),
|
||||
journal.set (row, 1, OldDuration (total_time).formatPrecise (),
|
||||
(context.color () ? Color ("bold") : Color ()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,35 +238,35 @@ int CmdStats::execute (std::string& output)
|
|||
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_CMD_STATS_USED_FOR);
|
||||
view.set (row, 1, Duration (latest - earliest).format ());
|
||||
view.set (row, 1, OldDuration (latest - earliest).format ());
|
||||
}
|
||||
|
||||
if (totalT)
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_CMD_STATS_ADD_EVERY);
|
||||
view.set (row, 1, Duration (((latest - earliest) / totalT)).format ());
|
||||
view.set (row, 1, OldDuration (((latest - earliest) / totalT)).format ());
|
||||
}
|
||||
|
||||
if (completedT)
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_CMD_STATS_COMP_EVERY);
|
||||
view.set (row, 1, Duration ((latest - earliest) / completedT).format ());
|
||||
view.set (row, 1, OldDuration ((latest - earliest) / completedT).format ());
|
||||
}
|
||||
|
||||
if (deletedT)
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_CMD_STATS_DEL_EVERY);
|
||||
view.set (row, 1, Duration ((latest - earliest) / deletedT).format ());
|
||||
view.set (row, 1, OldDuration ((latest - earliest) / deletedT).format ());
|
||||
}
|
||||
|
||||
if (pendingT || completedT)
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_CMD_STATS_AVG_PEND);
|
||||
view.set (row, 1, Duration ((int) ((daysPending / (pendingT + completedT)) * 86400)).format ());
|
||||
view.set (row, 1, OldDuration ((int) ((daysPending / (pendingT + completedT)) * 86400)).format ());
|
||||
}
|
||||
|
||||
if (totalT)
|
||||
|
|
|
@ -159,7 +159,7 @@ int CmdSummary::execute (std::string& output)
|
|||
|
||||
view.set (row, 1, countPending[i->first]);
|
||||
if (counter[i->first])
|
||||
view.set (row, 2, Duration ((int) (sumEntry[i->first] / (double)counter[i->first])).format ());
|
||||
view.set (row, 2, OldDuration ((int) (sumEntry[i->first] / (double)counter[i->first])).format ());
|
||||
|
||||
int c = countCompleted[i->first];
|
||||
int p = countPending[i->first];
|
||||
|
|
|
@ -552,7 +552,7 @@ void Command::modify_task (
|
|||
long l = (long) strtod (result.c_str (), NULL);
|
||||
if (labs (l) < 5 * 365 * 86400)
|
||||
{
|
||||
Duration dur (value);
|
||||
OldDuration dur (value);
|
||||
Date now;
|
||||
now += l;
|
||||
task.set (name, now.toEpochString ());
|
||||
|
@ -564,7 +564,7 @@ void Command::modify_task (
|
|||
}
|
||||
}
|
||||
|
||||
// Durations too.
|
||||
// OldDurations too.
|
||||
else if (name == "recur" ||
|
||||
column->type () == "duration")
|
||||
{
|
||||
|
@ -577,7 +577,7 @@ void Command::modify_task (
|
|||
std::string result = e.evalExpression (task);
|
||||
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
||||
|
||||
Duration d (value);
|
||||
OldDuration d (value);
|
||||
|
||||
// Deliberately storing the 'raw' value, which is necessary for
|
||||
// durations like 'weekday'..
|
||||
|
|
|
@ -207,7 +207,7 @@ std::string taskInfoDifferences (const Task& before, const Task& after, const st
|
|||
else if (*name == "start")
|
||||
{
|
||||
out << format (STRING_FEEDBACK_ATT_DEL_DUR, ucFirst (*name),
|
||||
Duration(current_timestamp - last_timestamp).formatPrecise())
|
||||
OldDuration(current_timestamp - last_timestamp).formatPrecise())
|
||||
<< "\n";
|
||||
}
|
||||
else
|
||||
|
|
|
@ -337,7 +337,7 @@ Date getNextRecurrence (Date& current, std::string& period)
|
|||
// If the period is an 'easy' one, add it to current, and we're done.
|
||||
// If it throws an error, the duration was not recognized.
|
||||
int secs = 0;
|
||||
Duration du (period);
|
||||
OldDuration du (period);
|
||||
secs = du;
|
||||
|
||||
return current + secs;
|
||||
|
|
|
@ -218,8 +218,8 @@ static bool sort_compare (int left, int right)
|
|||
if (left_string == right_string)
|
||||
continue;
|
||||
|
||||
Duration left_duration (left_string);
|
||||
Duration right_duration (right_string);
|
||||
OldDuration left_duration (left_string);
|
||||
OldDuration right_duration (right_string);
|
||||
return ascending ? (left_duration < right_duration)
|
||||
: (left_duration > right_duration);
|
||||
}
|
||||
|
@ -269,8 +269,8 @@ static bool sort_compare (int left, int right)
|
|||
if (left_string == right_string)
|
||||
continue;
|
||||
|
||||
Duration left_duration (left_string);
|
||||
Duration right_duration (right_string);
|
||||
OldDuration left_duration (left_string);
|
||||
OldDuration right_duration (right_string);
|
||||
return ascending ? (left_duration < right_duration)
|
||||
: (left_duration > right_duration);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue