Merge branch '2.3.0' into 2.4.0
Conflicts: AUTHORS CMakeLists.txt NEWS src/A3.cpp src/CMakeLists.txt src/Config.cpp src/Duration.cpp src/Duration.h src/Nibbler.cpp src/Nibbler.h src/RX.cpp src/RX.h src/columns/ColDate.cpp src/columns/ColScheduled.cpp src/commands/Command.cpp src/legacy.cpp src/utf8.cpp src/utf8.h test/CMakeLists.txt test/bug.mergedeps.t.postponed test/duration.t.cpp test/merge.duplicates.t test/merge.simple_duplication.t test/merge.t test/nibbler.t.cpp test/roundtrip.t test/rx.t.cpp test/utf8.t.cpp
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cmake.h>
|
||||
#include <math.h>
|
||||
#include <Context.h>
|
||||
#include <ColDate.h>
|
||||
@@ -49,6 +49,8 @@ ColumnDate::ColumnDate ()
|
||||
_styles.push_back ("epoch");
|
||||
_styles.push_back ("iso");
|
||||
_styles.push_back ("age");
|
||||
_styles.push_back ("remaining");
|
||||
_styles.push_back ("countdown");
|
||||
|
||||
Date now;
|
||||
now -= 125; // So that "age" is non-zero.
|
||||
@@ -57,6 +59,8 @@ ColumnDate::ColumnDate ()
|
||||
_examples.push_back (now.toEpochString ());
|
||||
_examples.push_back (now.toISO ());
|
||||
_examples.push_back (OldDuration (Date () - now).formatCompact ());
|
||||
_examples.push_back ("");
|
||||
_examples.push_back (OldDuration (Date () - now).format ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -78,7 +82,7 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim
|
||||
|
||||
if (task.has (_name))
|
||||
{
|
||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
||||
Date date (task.get_date (_name));
|
||||
|
||||
if (_style == "default" ||
|
||||
_style == "formatted")
|
||||
@@ -97,7 +101,6 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim
|
||||
}
|
||||
else if (_style == "countdown")
|
||||
{
|
||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
||||
Date now;
|
||||
minimum = maximum = OldDuration (now - date).format ().length ();
|
||||
}
|
||||
@@ -118,6 +121,12 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim
|
||||
Date now;
|
||||
minimum = maximum = OldDuration (now - date).formatCompact ().length ();
|
||||
}
|
||||
else if (_style == "remaining")
|
||||
{
|
||||
Date now;
|
||||
if (date > now)
|
||||
minimum = maximum = Duration (date - now).format ().length ();
|
||||
}
|
||||
else
|
||||
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||
}
|
||||
@@ -132,6 +141,8 @@ void ColumnDate::render (
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
Date date (task.get_date (_name));
|
||||
|
||||
if (_style == "default" ||
|
||||
_style == "formatted")
|
||||
{
|
||||
@@ -148,12 +159,10 @@ void ColumnDate::render (
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
leftJustify (
|
||||
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
||||
.toString (format), width)));
|
||||
date.toString (format), width)));
|
||||
}
|
||||
else if (_style == "countdown")
|
||||
{
|
||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
||||
Date now;
|
||||
|
||||
lines.push_back (
|
||||
@@ -166,28 +175,24 @@ void ColumnDate::render (
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (
|
||||
format (Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
||||
.toJulian (), 13, 12), width)));
|
||||
format (date.toJulian (), 13, 12), width)));
|
||||
}
|
||||
else if (_style == "epoch")
|
||||
{
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (
|
||||
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
||||
.toEpochString (), width)));
|
||||
date.toEpochString (), width)));
|
||||
}
|
||||
else if (_style == "iso")
|
||||
{
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
leftJustify (
|
||||
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
||||
.toISO (), width)));
|
||||
date.toISO (), width)));
|
||||
}
|
||||
else if (_style == "age")
|
||||
{
|
||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
||||
Date now;
|
||||
|
||||
lines.push_back (
|
||||
@@ -195,6 +200,17 @@ void ColumnDate::render (
|
||||
leftJustify (
|
||||
OldDuration (now - date).formatCompact (), width)));
|
||||
}
|
||||
else if (_style == "remaining")
|
||||
{
|
||||
Date now;
|
||||
if (date > now)
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (
|
||||
Duration (date - now).format (), width)));
|
||||
else
|
||||
lines.push_back ("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user