mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
CmdTimesheet: Migrated from ISO8601d to Datetime
This commit is contained in:
parent
a81e66b609
commit
ead550cbef
1 changed files with 13 additions and 13 deletions
|
@ -31,7 +31,7 @@
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Filter.h>
|
#include <Filter.h>
|
||||||
#include <Table.h>
|
#include <Table.h>
|
||||||
#include <ISO8601.h>
|
#include <Datetime.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
|
@ -64,18 +64,18 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
std::vector <Task> all = context.tdb2.all_tasks ();
|
std::vector <Task> all = context.tdb2.all_tasks ();
|
||||||
|
|
||||||
// What day of the week does the user consider the first?
|
// What day of the week does the user consider the first?
|
||||||
int weekStart = ISO8601d::dayOfWeek (context.config.get ("weekstart"));
|
int weekStart = Datetime::dayOfWeek (context.config.get ("weekstart"));
|
||||||
if (weekStart != 0 && weekStart != 1)
|
if (weekStart != 0 && weekStart != 1)
|
||||||
throw std::string (STRING_DATE_BAD_WEEKSTART);
|
throw std::string (STRING_DATE_BAD_WEEKSTART);
|
||||||
|
|
||||||
// Determine the date of the first day of the most recent report.
|
// Determine the date of the first day of the most recent report.
|
||||||
ISO8601d today;
|
Datetime today;
|
||||||
ISO8601d start;
|
Datetime start;
|
||||||
start -= (((today.dayOfWeek () - weekStart) + 7) % 7) * 86400;
|
start -= (((today.dayOfWeek () - weekStart) + 7) % 7) * 86400;
|
||||||
|
|
||||||
// Roll back to midnight.
|
// Roll back to midnight.
|
||||||
start = ISO8601d (start.month (), start.day (), start.year ());
|
start = Datetime (start.year (), start.month (), start.day ());
|
||||||
ISO8601d end = start + (7 * 86400);
|
Datetime end = start + (7 * 86400);
|
||||||
|
|
||||||
// Determine how many reports to run.
|
// Determine how many reports to run.
|
||||||
int quantity = 1;
|
int quantity = 1;
|
||||||
|
@ -86,7 +86,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
for (int week = 0; week < quantity; ++week)
|
for (int week = 0; week < quantity; ++week)
|
||||||
{
|
{
|
||||||
ISO8601d endString (end);
|
Datetime endString (end);
|
||||||
endString -= 86400;
|
endString -= 86400;
|
||||||
|
|
||||||
std::string title = start.toString (context.config.get ("dateformat"))
|
std::string title = start.toString (context.config.get ("dateformat"))
|
||||||
|
@ -121,7 +121,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
// If task completed within range.
|
// If task completed within range.
|
||||||
if (task.getStatus () == Task::completed)
|
if (task.getStatus () == Task::completed)
|
||||||
{
|
{
|
||||||
ISO8601d compDate (task.get_date ("end"));
|
Datetime compDate (task.get_date ("end"));
|
||||||
if (compDate >= start && compDate < end)
|
if (compDate >= start && compDate < end)
|
||||||
{
|
{
|
||||||
Color c;
|
Color c;
|
||||||
|
@ -135,7 +135,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
|
|
||||||
if(task.has ("due"))
|
if(task.has ("due"))
|
||||||
{
|
{
|
||||||
ISO8601d dt (task.get_date ("due"));
|
Datetime dt (task.get_date ("due"));
|
||||||
completed.set (row, 2, dt.toString (format));
|
completed.set (row, 2, dt.toString (format));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
for (auto& ann : annotations)
|
for (auto& ann : annotations)
|
||||||
description += '\n'
|
description += '\n'
|
||||||
+ std::string (indent, ' ')
|
+ std::string (indent, ' ')
|
||||||
+ ISO8601d (ann.first.substr (11)).toString (context.config.get ("dateformat"))
|
+ Datetime (ann.first.substr (11)).toString (context.config.get ("dateformat"))
|
||||||
+ ' '
|
+ ' '
|
||||||
+ ann.second;
|
+ ann.second;
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
if (task.getStatus () == Task::pending &&
|
if (task.getStatus () == Task::pending &&
|
||||||
task.has ("start"))
|
task.has ("start"))
|
||||||
{
|
{
|
||||||
ISO8601d startDate (task.get_date ("start"));
|
Datetime startDate (task.get_date ("start"));
|
||||||
if (startDate >= start && startDate < end)
|
if (startDate >= start && startDate < end)
|
||||||
{
|
{
|
||||||
Color c;
|
Color c;
|
||||||
|
@ -191,7 +191,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
|
|
||||||
if (task.has ("due"))
|
if (task.has ("due"))
|
||||||
{
|
{
|
||||||
ISO8601d dt (task.get_date ("due"));
|
Datetime dt (task.get_date ("due"));
|
||||||
started.set (row, 2, dt.toString (format));
|
started.set (row, 2, dt.toString (format));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
for (auto& ann : annotations)
|
for (auto& ann : annotations)
|
||||||
description += '\n'
|
description += '\n'
|
||||||
+ std::string (indent, ' ')
|
+ std::string (indent, ' ')
|
||||||
+ ISO8601d (ann.first.substr (11)).toString (context.config.get ("dateformat"))
|
+ Datetime (ann.first.substr (11)).toString (context.config.get ("dateformat"))
|
||||||
+ ' '
|
+ ' '
|
||||||
+ ann.second;
|
+ ann.second;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue