Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/misc/tod.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/* 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);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.