Anonymous avatar Anonymous committed d8b804e Draft

Changed the interpretation of time slightly

Comments (0)

Files changed (1)

hoelaat/src/nederlands.c

 	return nums[i];
 }
 
+static const char *
+part_of_day_string(
+	int hour
+)
+{
+	if (hour == 0 || hour == 24)
+		return "midder-\nnacht";
+	else
+	if (hour == 6)
+		return "morgen";
+	else
+	if (hour == 12)
+		return "middag";
+	else
+	if (hour == 18)
+		return "avond";
+	else
+		return nums[0];
+}
+
+static const char *
+ampm_string(
+	int hour
+)
+{
+	if (hour < 6 || hour >= 24)
+		return "'s nachts";
+	else
+	if (hour < 12)
+		return "'s morgens";
+	else
+	if (hour < 18)
+		return "'s middags";
+	else
+		return "'s avonds";
+}
 
 static const char *
 hour_string(
 	int h
 )
 {
-	// only if it is actually midnight, not "before midnight"
-	if (h == 0)
-		return "midder-\nnacht";
-
-	if (h == 12)
-		return "middag";
-
-	if (h < 12)
+	if (h <= 12)
 		return nums[h];
 	else
 		return nums[h - 12];
 	int min
 )
 {
-	if (min == 0)
+	int display_hour = hour;
+	if (min == 0) // full hour
 	{
-		min_word.text = "";
-		rel_word.text = "";
+		min_word.text = nums[0];
+		rel_word.text = nums[0];
+		if (hour % 6 == 0) // transition between different parts of the day (morning, afternoon, evening, night)
+			hour_word.text = part_of_day_string(hour);
+		else // other full hours
+			hour_word.text = hour_string(hour);
+		ampm_word.text = nums[0];
 	} else
 	if (min <= 15)
 	{
 		// over the kwart
 		min_word.text = min_string(30 - min);
 		rel_word.text = "voor half";
-		hour++;
+		display_hour++;
 	} else
 	if (min == 30)
 	{
 		// just the half
-		min_word.text = "";
+		min_word.text = nums[0];
 		rel_word.text = "half";
-		hour++;
+		display_hour++;
 	} else
 	if (min < 45)
 	{
 		// over the half
 		min_word.text = min_string(min - 30);
 		rel_word.text = "over half";
-		hour++;
+		display_hour++;
 	} else
 	if (min == 45)
 	{
 		// just the kwart
-		min_word.text = "";
+		min_word.text = nums[0];
 		rel_word.text = "kwart voor";
-		hour++;
+		display_hour++;
 	} else
 	if (min < 60)
 	{
 		// over the kwart
 		min_word.text = min_string(60 - min);
 		rel_word.text = "voor";
-		hour++;
+		display_hour++;
+	}
+	
+	if (min != 0)
+	{
+		hour_word.text = hour_string(display_hour);
+		ampm_word.text = ampm_string(hour);
 	}
 
-	hour_word.text = hour_string(hour);
-
-	// at midnight and noon do not display an am/pm notation
-	// but don't say "before midnight"
-	if (hour == 0 || hour == 12)
-	{
-		// nothing to do
-		ampm_word.text = "";
-	} else
-	if (hour < 6)
-		ampm_word.text = "'s nachts";
-	else
-	if (hour <= 12)
-		ampm_word.text = "'s morgens";
-	else
-	if (hour <= 17)
-		ampm_word.text = "'s middags";
-	else
-	if (hour <= 24)
-		ampm_word.text = "'s avonds";
 }
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.