Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extract get_hour_string function

  • Loading branch information...
commit 37785da749072d166296958349fd1dc881337224 1 parent b51accb
@caio authored
Showing with 7 additions and 1 deletion.
  1. +5 −1 src/fuzzyclock.c
  2. +2 −0  src/fuzzyclock.h
View
6 src/fuzzyclock.c
@@ -32,6 +32,10 @@ char* FUZZY_MSG[] = {
"five to %s\n",
};
+char* const get_hour_string(int hour) {
+ return HOUR_NAMES[(hour - 1) % 12];
+}
+
void get_fuzzy_time(struct tm* clock, char* buffer) {
int index = 0;
int hour = clock->tm_hour;
@@ -44,7 +48,7 @@ void get_fuzzy_time(struct tm* clock, char* buffer) {
if (index > 6) { hour++; }
char* timestr = FUZZY_MSG[index];
- char* hourname = HOUR_NAMES[(hour - 1) % 12];
+ char* hourname = get_hour_string(hour);
snprintf(buffer, MAX_MSG_SIZE, timestr, hourname);
}
View
2  src/fuzzyclock.h
@@ -8,4 +8,6 @@
void get_fuzzy_time(struct tm*, char*);
+char* const get_hour_string(int hour);
+
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.