Permalink
Browse files

CmdHistory: repeat unit if a larger unit changes

In history and ghistory commands, repeat the smaller units when a larger unit
changes.  For example, if January 2019 is displayed immediately after January
2018, re-show the "January" label instead of only showing the year change.
  • Loading branch information...
janikrabe authored and pbeckingham committed Feb 1, 2019
1 parent 16d55ed commit a8acff9f7f78cee0402b2f9bcfc9ef398e6c9b34
Showing with 20 additions and 8 deletions.
  1. +20 −8 src/commands/CmdHistory.cpp
@@ -539,10 +539,13 @@ class DailyHistoryStrategy
int last_m, last_d, last_y;
last_dt.toYMD (last_y, last_m, last_d);

if ((y != last_y) || (lastTime == 0))
bool y_changed = (y != last_y) || (lastTime == 0);
bool m_changed = (m != last_m) || (lastTime == 0);

if (y_changed)
view.set (row, 0, y);

if ((m != last_m) || (lastTime == 0))
if (y_changed || m_changed)
view.set (row, 1, Datetime::monthName (m));

view.set (row, 2, d);
@@ -586,10 +589,13 @@ class DailyGHistoryStrategy
int last_m, last_d, last_y;
last_dt.toYMD (last_y, last_m, last_d);

if ((y != last_y) || (lastTime == 0))
bool y_changed = (y != last_y) || (lastTime == 0);
bool m_changed = (m != last_m) || (lastTime == 0);

if (y_changed)
view.set (row, 0, y);

if ((m != last_m) || (lastTime == 0))
if (y_changed || m_changed)
view.set (row, 1, Datetime::monthName (m));

view.set (row, 2, d);
@@ -633,10 +639,13 @@ class WeeklyHistoryStrategy
int last_m, last_d, last_y;
last_dt.toYMD (last_y, last_m, last_d);

if ((y != last_y) || (lastTime == 0))
bool y_changed = (y != last_y) || (lastTime == 0);
bool m_changed = (m != last_m) || (lastTime == 0);

if (y_changed)
view.set (row, 0, y);

if ((m != last_m) || (lastTime == 0))
if (y_changed || m_changed)
view.set (row, 1, Datetime::monthName (m));

view.set (row, 2, d);
@@ -680,10 +689,13 @@ class WeeklyGHistoryStrategy
int last_m, last_d, last_y;
last_dt.toYMD (last_y, last_m, last_d);

if ((y != last_y) || (lastTime == 0))
bool y_changed = (y != last_y) || (lastTime == 0);
bool m_changed = (m != last_m) || (lastTime == 0);

if (y_changed)
view.set (row, 0, y);

if ((m != last_m) || (lastTime == 0))
if (y_changed || m_changed)
view.set (row, 1, Datetime::monthName (m));

view.set (row, 2, d);

0 comments on commit a8acff9

Please sign in to comment.