/* tod.c - print time in human */
#include <u.h>
#include <libc.h>
char *min[] = {
"%s O'clock\n", "%s O five\n", "%s ten\n",
"a quarter past %s\n", "%s twenty\n",
"%s twenty five\n", "half past %s\n",
"twenty five to %s\n", "twenty to %s\n",
"a quarter to %s\n", "ten to %s\n", "five to %s\n" };
char *hrs[] = {
"twelve", "one", "two", "three", "four", "five", "six",
"seven", "eight", "nine", "ten", "eleven", "twelve" };
void
main(void)
{
int m, h;
Tm *t;
t = localtime(time(nil));
m = (t->min + 2) / 5;
if (m > 6)
t->hour++;
h = t->hour % 12;
if (m >= 12)
m = 0;
print("It's ");
print(min[m], hrs[h]);
exits(0);
}
|