# 2.11BSD#431 - /usr/src/libexec/getty/get_date.c

##### Functions

    get_date          X

##### Macros

    AM                X
    PM                X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #if !defined(lint) && defined(DOSCCS)
       8: static char sccsid[] = "@(#)get_date.c	5.1.1 (2.11BSD GTE) 12/9/94";
       9: #endif
      10:
      11: #include <stdio.h>
      12: #include <sys/time.h>
      13:
      14: static char *days[] = {
      15:     "Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"
      16: };
      17:
      18: static char *months[] = {
      19:     "Jan", "Feb", "Mar", "Apr", "May", "June",
      20:     "July", "Aug", "Sept", "Oct", "Nov", "Dec"
      21: };
      22:
      23: #define AM "am"
      24: #define PM "pm"
      25:
      26: get_date(datebuffer)
      27:     char *datebuffer;
      28: {
      29:     register struct tm *tmp;
      30:     struct timeval tv;
      31:     int realhour;
      32:     register char *zone;
      33:
      34:     gettimeofday(&tv, 0);
      35:     tmp = localtime(&tv.tv_sec);
      36:
      37:     realhour = tmp->tm_hour;
      38:     zone = AM;          /* default to morning */
      39:     if (tmp->tm_hour == 0)
      40:         realhour = 12;      /* midnight */
      41:     else if (tmp->tm_hour == 12)
      42:         zone = PM;      /* noon */
      43:     else if (tmp->tm_hour >= 13 && tmp->tm_hour <= 23) { /* afternoon */
      44:         realhour = realhour - 12;
      45:         zone = PM;
      46:     }
      47:
      48:     /* format is '8:10pm on Sunday, 16 Sept 1973' */
      49:
      50:     sprintf(datebuffer, "%d:%02d%s on %s, %d %s %d",
      51:         realhour,
      52:         tmp->tm_min,
      53:         zone,
      54:         days[tmp->tm_wday],
      55:         tmp->tm_mday,
      56:         months[tmp->tm_mon],
      57:         1900 + tmp->tm_year);
      58: }

#### Defined functions

get_date defined in line 26; used 1 times

- in /usr/src/libexec/getty/main.c line 441

#### Defined variables

days defined in line 14; used 1 times

- in line 54

months defined in line 18; used 1 times

- in line 56

sccsid defined in line 8; never used

#### Defined macros

AM defined in line 23; used 1 times

- in line 38

PM defined in line 24; used 2 times

- in line 42-45(2)

Last modified: 1994-12-10 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 614 |