mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Bug
- Fixed bug where '6 months' was interpreted as 180 days, but when rendered was shown as '5 months' (thanks to Aikido Guy). - Multiple unit test corrections.
This commit is contained in:
parent
d4cc4c5745
commit
2203d3364d
3 changed files with 56 additions and 54 deletions
|
@ -236,8 +236,8 @@ std::string Duration::format () const
|
|||
sprintf (formatted, "%s%.1f yrs", (_negative ? "-" : ""), (days / 365));
|
||||
else if (_secs > 86400 * 84)
|
||||
sprintf (formatted, "%s%1d mth%s",
|
||||
(_negative ? "-" : ""), (int) (float) (days / 30.6),
|
||||
((int) (float) (days / 30.6) == 1 ? "" : "s"));
|
||||
(_negative ? "-" : ""), (int) (float) (days / 30),
|
||||
((int) (float) (days / 30) == 1 ? "" : "s"));
|
||||
else if (_secs > 86400 * 13)
|
||||
sprintf (formatted, "%s%d wk%s",
|
||||
(_negative ? "-" : ""), (int) (float) (days / 7.0),
|
||||
|
@ -270,12 +270,12 @@ std::string Duration::formatCompact () const
|
|||
char formatted[24];
|
||||
float days = (float) _secs / 86400.0;
|
||||
|
||||
if (_secs >= 86400 * 365) sprintf (formatted, "%s%.1fy", (_negative ? "-" : ""), (days / 365));
|
||||
else if (_secs >= 86400 * 84) sprintf (formatted, "%s%1dmo", (_negative ? "-" : ""), (int) (float) (days / 30.6));
|
||||
if (_secs >= 86400 * 365) sprintf (formatted, "%s%.1fy", (_negative ? "-" : ""), (days / 365.0));
|
||||
else if (_secs >= 86400 * 84) sprintf (formatted, "%s%1dmo", (_negative ? "-" : ""), (int) (days / 30));
|
||||
else if (_secs >= 86400 * 13) sprintf (formatted, "%s%dwk", (_negative ? "-" : ""), (int) (float) (days / 7.0));
|
||||
else if (_secs >= 86400) sprintf (formatted, "%s%dd", (_negative ? "-" : ""), (int) days);
|
||||
else if (_secs >= 3600) sprintf (formatted, "%s%dh", (_negative ? "-" : ""), (int) (float) (_secs / 3600));
|
||||
else if (_secs >= 60) sprintf (formatted, "%s%dm", (_negative ? "-" : ""), (int) (float) (_secs / 60));
|
||||
else if (_secs >= 3600) sprintf (formatted, "%s%dh", (_negative ? "-" : ""), (int) (_secs / 3600));
|
||||
else if (_secs >= 60) sprintf (formatted, "%s%dm", (_negative ? "-" : ""), (int) (_secs / 60));
|
||||
else if (_secs >= 1) sprintf (formatted, "%s%ds", (_negative ? "-" : ""), (int) _secs);
|
||||
else strcpy (formatted, "-");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue