Commits

Trammell Hudson committed 62703a6 Draft

Make text output more contextual

Comments (0)

Files changed (1)

 	"twelve",
 	"thirteen",
 	"fourteen",
-	"fifteen",
+	"a quarter",
 	"sixteen",
 	"seventeen",
 	"eightteen",
 
 
 static void
+hour_output(
+	uint8_t hour
+)
+{
+	if (hour == 0 || hour == 24)
+	{
+		strcat(scroll_output, "midnight");
+	} else
+	if (hour < 12)
+	{
+		strcat(scroll_output, numbers[hour+1]);
+		strcat(scroll_output, " in the morning");
+	} else
+	if (hour == 12)
+	{
+		strcat(scroll_output, "noon");
+	} else
+	if (hour < 17)
+	{
+		strcat(scroll_output, numbers[hour-12]);
+		strcat(scroll_output, " in the afternoon");
+	} else {
+		strcat(scroll_output, numbers[hour-12]);
+		strcat(scroll_output, " in the evening");
+	}
+}
+
+static void
 word_clock(void)
 {
 	scroll_output[0] = '\0';
 	{
 		if (min != 0)
 		{
-			if (min == 15)
-				strcat(scroll_output, "a quarter");
-			else
-				strcat(scroll_output, numbers[min]);
+			strcat(scroll_output, numbers[min]);
 			strcat(scroll_output, " past ");
 		}
 
 		else
 			strcat(scroll_output, numbers[hour]);
 	} else {
-		if (min == 45)
-			strcat(scroll_output, "a quarter");
-		else
-			strcat(scroll_output, numbers[60-min]);
+		strcat(scroll_output, numbers[60-min]);
 		strcat(scroll_output, " before ");
-		if (hour == 11)
-			strcat(scroll_output, "noon");
-		else
-		if (hour == 23)
-			strcat(scroll_output, "midnight");
-		else
-			strcat(scroll_output, numbers[hour+1]);
+		hour_output(hour + 1);
 	}
 
 	strcat(scroll_output, "      ");