mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
ISO8601d: Conversion from Date to ISO8601d
This commit is contained in:
parent
f32e53c7d6
commit
68c6afbdd4
4 changed files with 29 additions and 29 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <Lexer.h>
|
||||
#include <Nibbler.h>
|
||||
#ifdef NIBBLER_FEATURE_DATE
|
||||
#include <ISO8601.h>
|
||||
#include <Date.h>
|
||||
#endif
|
||||
#ifdef NIBBLER_FEATURE_REGEX
|
||||
|
@ -818,8 +819,8 @@ bool Nibbler::getDate (const std::string& format, time_t& t)
|
|||
! Lexer::isDigit ((*_input)[i + 1]) &&
|
||||
! Lexer::isDigit ((*_input)[i + 2]))
|
||||
{
|
||||
wday = Date::dayOfWeek (_input->substr (i, 3).c_str ());
|
||||
i += (format[f] == 'a') ? 3 : Date::dayName (wday).size ();
|
||||
wday = ISO8601d::dayOfWeek (_input->substr (i, 3).c_str ());
|
||||
i += (format[f] == 'a') ? 3 : ISO8601d::dayName (wday).size ();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
@ -834,8 +835,8 @@ bool Nibbler::getDate (const std::string& format, time_t& t)
|
|||
{
|
||||
if (month != -1)
|
||||
return false;
|
||||
month = Date::monthOfYear (_input->substr (i, 3).c_str());
|
||||
i += (format[f] == 'b') ? 3 : Date::monthName (month).size ();
|
||||
month = ISO8601d::monthOfYear (_input->substr (i, 3).c_str());
|
||||
i += (format[f] == 'b') ? 3 : ISO8601d::monthName (month).size ();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <cmake.h>
|
||||
#include <Context.h>
|
||||
#include <ISO8601.h>
|
||||
#include <Date.h>
|
||||
#include <ColUDA.h>
|
||||
#include <text.h>
|
||||
#include <utf8.h>
|
||||
|
@ -89,14 +88,14 @@ void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximu
|
|||
// rc.report.<report>.dateformat
|
||||
// rc.dateformat.report
|
||||
// rc.dateformat
|
||||
Date date ((time_t) strtol (value.c_str (), NULL, 10));
|
||||
ISO8601d date ((time_t) strtol (value.c_str (), NULL, 10));
|
||||
std::string format = context.config.get ("report." + _report + ".dateformat");
|
||||
if (format == "")
|
||||
format = context.config.get ("dateformat.report");
|
||||
if (format == "")
|
||||
format = context.config.get ("dateformat");
|
||||
|
||||
minimum = maximum = Date::length (format);
|
||||
minimum = maximum = ISO8601d::length (format);
|
||||
}
|
||||
else if (_type == "duration")
|
||||
{
|
||||
|
@ -153,8 +152,7 @@ void ColumnUDA::render (
|
|||
lines.push_back (
|
||||
color.colorize (
|
||||
leftJustify (
|
||||
Date ((time_t) strtol (value.c_str (), NULL, 10))
|
||||
.toString (format), width)));
|
||||
ISO8601d ((time_t) strtol (value.c_str (), NULL, 10)).toString (format), width)));
|
||||
}
|
||||
else if (_type == "duration")
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@ int CmdCalendar::execute (std::string& output)
|
|||
// Set up a vector of months, for autoComplete.
|
||||
std::vector <std::string> monthNames;
|
||||
for (int i = 1; i <= 12; ++i)
|
||||
monthNames.push_back (lowerCase (Date::monthName (i)));
|
||||
monthNames.push_back (lowerCase (ISO8601d::monthName (i)));
|
||||
|
||||
// For autoComplete results.
|
||||
std::vector <std::string> matches;
|
||||
|
@ -140,7 +140,7 @@ int CmdCalendar::execute (std::string& output)
|
|||
// "January" etc.
|
||||
else if (autoComplete (lowerCase (arg), monthNames, matches, context.config.getInteger ("abbreviation.minimum")) == 1)
|
||||
{
|
||||
argMonth = Date::monthOfYear (matches[0]);
|
||||
argMonth = ISO8601d::monthOfYear (matches[0]);
|
||||
if (argMonth == -1)
|
||||
throw format (STRING_CMD_CAL_BAD_MONTH, arg);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ int CmdCalendar::execute (std::string& output)
|
|||
// Print month headers (cheating on the width settings, yes)
|
||||
for (int i = 0 ; i < monthsPerLine ; i++)
|
||||
{
|
||||
std::string month = Date::monthName (nextM);
|
||||
std::string month = ISO8601d::monthName (nextM);
|
||||
|
||||
// 12345678901234567890123456 = 26 chars wide
|
||||
// ^^ = center
|
||||
|
@ -426,7 +426,7 @@ std::string CmdCalendar::renderMonths (
|
|||
int monthsPerLine)
|
||||
{
|
||||
// What day of the week does the user consider the first?
|
||||
int weekStart = Date::dayOfWeek (context.config.get ("weekstart"));
|
||||
int weekStart = ISO8601d::dayOfWeek (context.config.get ("weekstart"));
|
||||
if (weekStart != 0 && weekStart != 1)
|
||||
throw std::string (STRING_CMD_CAL_SUN_MON);
|
||||
|
||||
|
@ -441,24 +441,24 @@ std::string CmdCalendar::renderMonths (
|
|||
if (weekStart == 1)
|
||||
{
|
||||
view.add (Column::factory ("string.right", " "));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (1), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (2), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (3), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (4), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (5), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (6), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (0), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (1), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (2), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (3), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (4), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (5), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (6), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (0), 0, 2)));
|
||||
}
|
||||
else
|
||||
{
|
||||
view.add (Column::factory ("string.right", " "));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (0), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (1), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (2), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (3), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (4), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (5), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (Date::dayName (6), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (0), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (1), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (2), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (3), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (4), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (5), 0, 2)));
|
||||
view.add (Column::factory ("string.right", utf8_substr (ISO8601d::dayName (6), 0, 2)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,7 +511,7 @@ std::string CmdCalendar::renderMonths (
|
|||
// Loop through days in month and add to table.
|
||||
for (int d = 1; d <= daysInMonth[mpl]; ++d)
|
||||
{
|
||||
Date temp (months[mpl], d, years[mpl]);
|
||||
ISO8601d temp (months[mpl], d, years[mpl]);
|
||||
int dow = temp.dayOfWeek ();
|
||||
int woy = temp.weekOfYear (weekStart);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
#include <ISO8601.h>
|
||||
#include <CmdHistory.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -136,7 +137,7 @@ int CmdHistoryMonthly::execute (std::string& output)
|
|||
view.set (row, 0, y);
|
||||
priorYear = y;
|
||||
}
|
||||
view.set (row, 1, Date::monthName(m));
|
||||
view.set (row, 1, ISO8601d::monthName(m));
|
||||
|
||||
int net = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue