File: date.c

package info (click to toggle)
heyu 1.28-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 360 kB
  • ctags: 278
  • sloc: ansic: 3,318; makefile: 134; sh: 72
file content (75 lines) | stat: -rwxr-xr-x 1,848 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

/*
 * Copyright 1986 by Larry Campbell, 73 Concord Street, Maynard MA 01754 USA
 * (maynard!campbell).  You may freely copy, use, and distribute this software
 * subject to the following restrictions:
 *
 *  1)	You may not charge money for it.
 *  2)	You may not remove or alter this copyright notice.
 *  3)	You may not claim you wrote it.
 *  4)	If you make improvements (or other changes), you are requested
 *	to send them to me, so there's a focal point for distributing
 *	improved versions.
 *
 * John Chmielewski (tesla!jlc until 9/1/86, then rogue!jlc) assisted
 * by doing the System V port and adding some nice features.  Thanks!
 */

 /* Changes for the CM11A made by Daniel Suthers, dbs@tanj.com */

#include <stdio.h>
#include <time.h>
#include "x10.h"
#include <unistd.h>
#ifdef SYSV
#include <sys/types.h>
#include <strings.h>
#endif

#include <sys/param.h>
#ifdef BEFORE
#include <sys/filsys.h>
#endif
#include "x10.h"

/* extern struct tm *localtime(); */

extern void error();

extern int
 Idays, Ihours, Iminutes;

/* ARGSUSED */

int c_date(argc, argv)
char *argv[];
{
    int  today;
    struct tm *tp;
    char RCSID[]= "@(#) $Id: date.c,v 1.7 1999/12/13 19:32:59 dbs Exp dbs $\n";
    extern int usage(), get_status(), dowX2U();
    time_t now;

    display(RCSID);
    if (argc != 2)
	usage(E_2MANY);
    time(&now);
    tp = localtime(&now);

    if( get_status() < 1 )
        error(" No reponse from CM11A.  Program exiting");
    today = dowX2U(Idays);
#ifndef POSIX
    while (tp->tm_wday % 7 != today)
	tp->tm_wday++, tp->tm_mday++;
#endif

#ifdef VENIX
    (void) printf("%2d%02d%02d%02d%02d\n",
	     tp->tm_year % 100, tp->tm_mon + 1, tp->tm_mday, Ihours, Iminutes);
#else
    (void) printf("%02d%02d%02d%02d%2d\n",
	     tp->tm_mon + 1, tp->tm_mday, Ihours, Iminutes, tp->tm_year % 100);
#endif
    return(0);
}