Skip to content

Commit

Permalink
Merge pull request #94 from arieboven/master
Browse files Browse the repository at this point in the history
Update window when date string change
  • Loading branch information
anarcat authored Nov 21, 2021
2 parents 06d0d0b + 84fd64b commit f2f847c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ttyclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ update_hour(void)
ttyclock.date.minute[1] = ttyclock.tm->tm_min % 10;

/* Set date string */
strcpy(ttyclock.date.old_datestr, ttyclock.date.datestr);
strftime(tmpstr,
sizeof(tmpstr),
ttyclock.option.format,
Expand Down Expand Up @@ -242,6 +243,15 @@ draw_number(int n, int x, int y)
void
draw_clock(void)
{
if (ttyclock.option.date && !ttyclock.option.rebound &&
strcmp(ttyclock.date.datestr, ttyclock.date.old_datestr) != 0)
{
clock_move(ttyclock.geo.x,
ttyclock.geo.y,
ttyclock.geo.w,
ttyclock.geo.h);
}

/* Draw hour numbers */
draw_number(ttyclock.date.hour[0], 1, 1);
draw_number(ttyclock.date.hour[1], 1, 8);
Expand Down
1 change: 1 addition & 0 deletions ttyclock.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ typedef struct
unsigned int minute[2];
unsigned int second[2];
char datestr[256];
char old_datestr[256];
} date;

/* time.h utils */
Expand Down

0 comments on commit f2f847c

Please sign in to comment.