1: /* Copyright (c) 1979 Regents of the University of California */
   2: /*
   3:  * Print out the time to a human desirable
   4:  * accuracy.
   5:  *
   6:  * Author: Kurt Shoens (UCB) July 11, 1978
   7:  */
   8: 
   9: char *hourNames[] {
  10:     "midnight",
  11:     "one",
  12:     "two",
  13:     "three",
  14:     "four",
  15:     "five",
  16:     "six",
  17:     "seven",
  18:     "eight",
  19:     "nine",
  20:     "ten",
  21:     "eleven",
  22:     "noon",
  23:     0
  24: };
  25: 
  26: char *quadrants[] {
  27:     "o' clock",
  28:     "quarter past",
  29:     "half past",
  30:     "quarter 'til",
  31:     0
  32: };
  33: 
  34: main(argc, argv)
  35:     char **argv;
  36: {
  37:     int hour, *t, min, q, tv[2];
  38:     char *hs, *qs;
  39: 
  40:     time(tv);
  41:     t = localtime(tv);
  42:     hour = t[2];
  43:     min = t[1];
  44:     if (argc >= 3) {
  45:         hour = atoi(argv[1]);
  46:         min = atoi(argv[2]);
  47:     }
  48:     q = (min+8) / 15;
  49:     if (q >= 4) {
  50:         q = 0;
  51:         hour++;
  52:     }
  53:     if (q > 2)
  54:         hour++;
  55:     if (hour >= 24)
  56:         hour = 0;
  57:     if (hour > 12)
  58:         hour =- 12;
  59:     hs = hourNames[hour];
  60:     qs = quadrants[q];
  61:     if ((hour == 12 || hour == 0) && q == 0) {
  62:         *hs = raise(*hs);
  63:         printf("%s\n", hs);
  64:         exit(0);
  65:     }
  66:     if (q == 0) {
  67:         *hs = raise(*hs);
  68:         printf("%s %s\n", hs, qs);
  69:         exit(0);
  70:     }
  71:     *qs = raise(*qs);
  72:     printf("%s %s\n", qs, hs);
  73:     exit(0);
  74: }
  75: 
  76: /*
  77:  * Return the upper case version of the possibly
  78:  * lower case letter.
  79:  */
  80: 
  81: raise(c)
  82: {
  83:     if (c >= 'a' && c <= 'z')
  84:         c =+ 'A' - 'a';
  85:     return(c);
  86: }

Defined functions

main defined in line 34; never used
raise defined in line 81; used 3 times

Defined variables

hourNames defined in line 9; used 1 times
  • in line 59
quadrants defined in line 26; used 1 times
  • in line 60
Last modified: 1979-05-09
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 706
Valid CSS Valid XHTML 1.0 Strict