From 5706cca20723b94c14e0396b647539f9b850fd5d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 12 Apr 2014 14:12:59 -0400 Subject: [PATCH] TW-115 - TW-115 allow "0day" durations for UDAs. --- ChangeLog | 7 ++++--- src/Variant.cpp | 47 +++++++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f0ff1020..cececf08f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,9 +3,6 @@ - TD-42 Cannot compile taskd - GNUTLS_VERSION undefined in diag.cpp (thanks to Michele Vetturi). - TD-45 Fix preprocessor define (thanks to Jochen Sprickerhof). -- TW-278 Cygwin throws warnings building mk_wcwidth() in wcwidth6.c. -- TW-1254 Calc command can segfault on negative numbers (thanks to Renato - Alves). - #1255 l10n translation utility improvements (thanks to Renato Alves). - #1473 Make TASK_RCDIR customizable (thanks to Elias Probst). - #1486 Truncated sentence in task-sync(5) manpage (thanks to Jakub Wilk). @@ -18,10 +15,14 @@ - #1508 Show command highlight configuration (thanks to Nicolas Appriou). - #1511 sync init crashes if client certification file is empty or invalid (thanks to Marton Suranyi). +- TW-115 allow "0day" durations for UDAs. - TW-197 New virtual tag READY. - TW-255 'Mask' instead of 'iMask' shown in info report (thanks to Benjamin Weber) - TW-261 Easy to create "not deletable" task (thanks to Jan Kunder). +- TW-278 Cygwin throws warnings building mk_wcwidth() in wcwidth6.c. +- TW-1254 Calc command can segfault on negative numbers (thanks to Renato + Alves). - TW-1255 New testing framework (thanks to Renato Alves). - TW-1257 The 'Syncing with :' message ignores verbosity tokens. - TW-1258 Portuguese Localization (thanks to Renato Alves). diff --git a/src/Variant.cpp b/src/Variant.cpp index af9716069..63877ea46 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -1302,28 +1302,35 @@ Variant::operator std::string () const { time_t t = _duration; - int seconds = t % 60; t /= 60; - int minutes = t % 60; t /= 60; - int hours = t % 24; t /= 24; - int days = t % 30; t /= 30; - int months = t % 12; t /= 12; - int years = t; - - std::stringstream s; - s << 'P'; - if (years) s << years << 'Y'; - if (months) s << months << 'M'; - if (days) s << days << 'D'; - - if (hours || minutes || seconds) + if (t) { - s << 'T'; - if (hours) s << hours << 'H'; - if (minutes) s << minutes << 'M'; - if (seconds) s << seconds << 'S'; - } + int seconds = t % 60; t /= 60; + int minutes = t % 60; t /= 60; + int hours = t % 24; t /= 24; + int days = t % 30; t /= 30; + int months = t % 12; t /= 12; + int years = t; - return s.str (); + std::stringstream s; + s << 'P'; + if (years) s << years << 'Y'; + if (months) s << months << 'M'; + if (days) s << days << 'D'; + + if (hours || minutes || seconds) + { + s << 'T'; + if (hours) s << hours << 'H'; + if (minutes) s << minutes << 'M'; + if (seconds) s << seconds << 'S'; + } + + return s.str (); + } + else + { + return "P0S"; + } } case type_unknown: